Skip to content

Commit

Permalink
[8.x] Add route caching integration tests (#37695)
Browse files Browse the repository at this point in the history
* Add route caching integration tests

* Apply fixes from StyleCI (#37694)
  • Loading branch information
driesvints authored Jun 15, 2021
1 parent 93db226 commit 6a3254a
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"guzzlehttp/guzzle": "^6.5.5|^7.0.1",
"league/flysystem-cached-adapter": "^1.0",
"mockery/mockery": "^1.4.2",
"orchestra/testbench-core": "^6.8",
"orchestra/testbench-core": "^6.23",
"pda/pheanstalk": "^4.0",
"phpunit/phpunit": "^8.5.8|^9.3.3",
"predis/predis": "^1.1.2",
Expand Down
13 changes: 13 additions & 0 deletions tests/Integration/Routing/Fixtures/redirect_routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

use Illuminate\Support\Facades\Route;

Route::redirect('/foo/1', '/foo/1/bar');

Route::get('/foo/1/bar', function () {
return 'Redirect response';
});

Route::get('/foo/1', function () {
return 'GET response';
});
11 changes: 11 additions & 0 deletions tests/Integration/Routing/Fixtures/wildcard_catch_all_routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Illuminate\Support\Facades\Route;

Route::get('/foo', function () {
return 'Regular route';
});

Route::get('{slug}', function () {
return 'Wildcard route';
});
30 changes: 30 additions & 0 deletions tests/Integration/Routing/RouteCachingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Illuminate\Tests\Integration\Routing;

use Orchestra\Testbench\TestCase;

class RouteCachingTest extends TestCase
{
public function testWildcardCatchAllRoutes()
{
$this->routes(__DIR__.'/Fixtures/wildcard_catch_all_routes.php');

$this->get('/foo')->assertSee('Regular route');
$this->get('/bar')->assertSee('Wildcard route');
}

public function testRedirectRoutes()
{
$this->routes(__DIR__.'/Fixtures/redirect_routes.php');

$this->post('/foo/1')->assertRedirect('/foo/1/bar');
$this->get('/foo/1/bar')->assertSee('Redirect response');
$this->get('/foo/1')->assertRedirect('/foo/1/bar');
}

protected function routes(string $file)
{
$this->defineCacheRoutes(file_get_contents($file));
}
}

0 comments on commit 6a3254a

Please sign in to comment.