Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #25962 [Routing] Fix trailing slash redirection for non-safe verb…
…s (nicolas-grekas) This PR was merged into the 2.7 branch. Discussion ---------- [Routing] Fix trailing slash redirection for non-safe verbs | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This test dumped matchers using the existing test cases for (Redirectable)UrlMatcher so that we are sure they behave the same. Fixes the differences found while doing so. Commits ------- ad593ae [Routing] Fix trailing slash redirection for non-safe verbs
- Loading branch information
Showing
8 changed files
with
203 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Symfony/Component/Routing/Tests/Matcher/DumpedRedirectableUrlMatcherTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Matcher; | ||
|
||
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; | ||
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface; | ||
use Symfony\Component\Routing\Matcher\UrlMatcher; | ||
use Symfony\Component\Routing\RouteCollection; | ||
use Symfony\Component\Routing\RequestContext; | ||
|
||
class DumpedRedirectableUrlMatcherTest extends RedirectableUrlMatcherTest | ||
{ | ||
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null) | ||
{ | ||
static $i = 0; | ||
|
||
$class = 'DumpedRedirectableUrlMatcher'.++$i; | ||
$dumper = new PhpMatcherDumper($routes); | ||
$dumpedRoutes = eval('?>'.$dumper->dump(array('class' => $class, 'base_class' => 'Symfony\Component\Routing\Tests\Matcher\TestDumpedRedirectableUrlMatcher'))); | ||
|
||
return $this->getMockBuilder($class) | ||
->setConstructorArgs(array($context ?: new RequestContext())) | ||
->setMethods(array('redirect')) | ||
->getMock(); | ||
} | ||
} | ||
|
||
class TestDumpedRedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface | ||
{ | ||
public function redirect($path, $route, $scheme = null) | ||
{ | ||
return array(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/Symfony/Component/Routing/Tests/Matcher/DumpedUrlMatcherTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Routing\Tests\Matcher; | ||
|
||
use Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper; | ||
use Symfony\Component\Routing\RouteCollection; | ||
use Symfony\Component\Routing\RequestContext; | ||
|
||
class DumpedUrlMatcherTest extends UrlMatcherTest | ||
{ | ||
/** | ||
* @expectedException \LogicException | ||
* @expectedExceptionMessage The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface. | ||
*/ | ||
public function testSchemeRequirement() | ||
{ | ||
parent::testSchemeRequirement(); | ||
} | ||
|
||
protected function getUrlMatcher(RouteCollection $routes, RequestContext $context = null) | ||
{ | ||
static $i = 0; | ||
|
||
$class = 'DumpedUrlMatcher'.++$i; | ||
$dumper = new PhpMatcherDumper($routes); | ||
$dumpedRoutes = eval('?>'.$dumper->dump(array('class' => $class))); | ||
|
||
return new $class($context ?: new RequestContext()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.