[Routing] Fix throwing NoConfigurationException instead of 405
This commit is contained in:
parent
946eefa284
commit
73269cfd0e
@ -154,7 +154,7 @@ EOF;
|
||||
}
|
||||
|
||||
// used to display the Welcome Page in apps that don't define a homepage
|
||||
$code .= " if ('/' === \$pathinfo) {\n";
|
||||
$code .= " if ('/' === \$pathinfo && !\$allow) {\n";
|
||||
$code .= " throw new Symfony\Component\Routing\Exception\NoConfigurationException();\n";
|
||||
$code .= " }\n";
|
||||
|
||||
@ -362,7 +362,7 @@ EOF;
|
||||
EOF;
|
||||
}
|
||||
} elseif ($methods) {
|
||||
$code .= <<<EOF
|
||||
$code .= <<<EOF
|
||||
if (!in_array($methodVariable, array('$methods'))) {
|
||||
\$allow = array_merge(\$allow, array('$methods'));
|
||||
goto $gotoname;
|
||||
|
@ -76,7 +76,7 @@ class UrlMatcher implements UrlMatcherInterface, RequestMatcherInterface
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$this->allow) {
|
||||
throw new NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
$canonicalMethod = 'GET';
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -371,7 +371,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
}
|
||||
not_nonsecure:
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
return array('_route' => 'with-condition');
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Matcher\UrlMatcher
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -240,7 +240,7 @@ class ProjectUrlMatcher extends Symfony\Component\Routing\Tests\Fixtures\Redirec
|
||||
|
||||
}
|
||||
|
||||
if ('/' === $pathinfo) {
|
||||
if ('/' === $pathinfo && !$allow) {
|
||||
throw new Symfony\Component\Routing\Exception\NoConfigurationException();
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,21 @@ class UrlMatcherTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testMethodNotAllowedOnRoot()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
$coll->add('foo', new Route('/', array(), array(), array(), '', array(), array('GET')));
|
||||
|
||||
$matcher = $this->getUrlMatcher($coll, new RequestContext('', 'POST'));
|
||||
|
||||
try {
|
||||
$matcher->match('/');
|
||||
$this->fail();
|
||||
} catch (MethodNotAllowedException $e) {
|
||||
$this->assertEquals(array('GET'), $e->getAllowedMethods());
|
||||
}
|
||||
}
|
||||
|
||||
public function testHeadAllowedWhenRequirementContainsGet()
|
||||
{
|
||||
$coll = new RouteCollection();
|
||||
|
Reference in New Issue
Block a user