Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge 5bff74b into ea15927
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Mar 7, 2018
2 parents ea15927 + 5bff74b commit ac7e685
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 38 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -25,7 +25,7 @@
"aura/router": "^3.1",
"fig/http-message-util": "^1.1.2",
"psr/http-message": "^1.0.1",
"zendframework/zend-expressive-router": "^3.0.0rc2"
"zendframework/zend-expressive-router": "^3.0.0rc3"
},
"require-dev": {
"malukenho/docheader": "^0.1.6",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 1 addition & 8 deletions src/AuraRouter.php
Expand Up @@ -146,14 +146,7 @@ private function marshalFailedRoute(
return RouteResult::fromRouteFailure($failedRoute->allows);
}

// Determine if the failed route allows ALL or NO HTTP methods
if ([] === $failedRoute->allows
&& ! $this->matchAuraRouteToRoute($failedRoute)
) {
return RouteResult::fromRouteFailure(Route::HTTP_METHOD_ANY);
}

return RouteResult::fromRouteFailure($failedRoute->allows ?: []);
return RouteResult::fromRouteFailure($failedRoute->allows ?: Route::HTTP_METHOD_ANY);
}

/**
Expand Down
24 changes: 1 addition & 23 deletions test/AuraRouterTest.php
Expand Up @@ -443,28 +443,6 @@ public function testFailureToMatchSubpathWhenRootPathRouteIsPresentShouldResultI
$this->assertFalse($result->isMethodFailure());
}

public function testMatchWhenNoHttpMethodsPresentShouldResultInRoutingFailure()
{
$uri = $this->prophesize(UriInterface::class);
$uri->getPath()->willReturn('/foo');

$request = $this->prophesize(ServerRequestInterface::class);
$request->getUri()->willReturn($uri);
$request->getMethod()->willReturn(RequestMethod::METHOD_GET);
$request->getServerParams()->willReturn([]);

// Not mocking the router container or Aura\Route; this particular test
// is testing how the parts integrate.
$router = new AuraRouter();
$router->addRoute(new Route('/foo', $this->getMiddleware(), []));

$result = $router->match($request->reveal());
$this->assertInstanceOf(RouteResult::class, $result);
$this->assertTrue($result->isFailure(), 'Routing did not fail, but should have');
$this->assertTrue($result->isMethodFailure(), 'Failure was not due to HTTP method, but should have been');
$this->assertEquals([], $result->getAllowedMethods(), 'Allowed methods should have been empty, but was not');
}

public function allHttpMethods()
{
return [
Expand Down Expand Up @@ -516,7 +494,7 @@ public function testFailedRoutingDueToUnknownCausesResultsInFailureRouteNotDueTo
// Not mocking the router container or Aura\Route; this particular test
// is testing how the parts integrate.
$router = new AuraRouter();
$router->addRoute(new Route('/foo', $this->getMiddleware(), []));
$router->addRoute(new Route('/foo', $this->getMiddleware(), [RequestMethod::METHOD_TRACE]));

$result = $router->match($request->reveal());
$this->assertInstanceOf(RouteResult::class, $result);
Expand Down

0 comments on commit ac7e685

Please sign in to comment.