Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Mar 7, 2020
1 parent 5743fdf commit f76b787
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/Illuminate/Routing/CompiledRouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Illuminate\Container\Container;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
Expand Down Expand Up @@ -122,7 +121,7 @@ public function match(Request $request)
} catch (ResourceNotFoundException | MethodNotAllowedException $e) {
try {
return $this->routes->match($request);
} catch (NotFoundHttpException | MethodNotAllowedHttpException $e) {
} catch (NotFoundHttpException $e) {
//
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/Integration/Routing/CompiledRouteCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,19 @@ public function testMatchingThrowsMethodNotAllowedHttpExceptionWhenMethodIsNotAl
$this->collection()->match(Request::create('/foo', 'POST'));
}

public function testMatchingThrowsMethodNotAllowedHttpExceptionWhenMethodIsNotAllowedWhileSameRouteIsAddedDynamically()
{
$this->routeCollection->add($this->newRoute('GET', '/', ['uses' => 'FooController@index']));

$routes = $this->collection();

$routes->add($this->newRoute('POST', '/', ['uses' => 'FooController@index']));

$this->expectException(MethodNotAllowedHttpException::class);

$routes->match(Request::create('/', 'PUT'));
}

public function testMatchingRouteWithSameDynamicallyAddedRouteAlwaysMatchesCachedOneFirst()
{
$this->routeCollection->add(
Expand Down

0 comments on commit f76b787

Please sign in to comment.