Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FrameworkBundle] Fix a bug in the RedirectableUrlMatcher
- Loading branch information
Showing
2 changed files
with
63 additions
and
3 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
61 changes: 61 additions & 0 deletions
61
src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RedirectableUrlMatcherTest.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,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony framework. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Routing; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Routing\Router; | ||
use Symfony\Component\Routing\Route; | ||
use Symfony\Component\Routing\RouteCollection; | ||
use Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher; | ||
use Symfony\Component\Routing\RequestContext; | ||
|
||
class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testRedirectWhenNoSlash() | ||
{ | ||
$coll = new RouteCollection(); | ||
$coll->add('foo', new Route('/foo/')); | ||
|
||
$matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext()); | ||
|
||
$this->assertEquals(array( | ||
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', | ||
'path' => '/foo/', | ||
'permanent' => true, | ||
'scheme' => null, | ||
'httpPort' => $context->getHttpPort(), | ||
'httpsPort' => $context->getHttpsPort(), | ||
'_route' => null, | ||
), | ||
$matcher->match('/foo') | ||
); | ||
} | ||
|
||
public function testSchemeRedirect() | ||
{ | ||
$coll = new RouteCollection(); | ||
$coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https'))); | ||
|
||
$matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext()); | ||
|
||
$this->assertEquals(array( | ||
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction', | ||
'path' => '/foo', | ||
'permanent' => true, | ||
'scheme' => 'https', | ||
'httpPort' => $context->getHttpPort(), | ||
'httpsPort' => $context->getHttpsPort(), | ||
'_route' => 'foo', | ||
), | ||
$matcher->match('/foo') | ||
); | ||
} | ||
} |