Skip to content

Commit 66d0d3d

Browse files
vicbfabpot
authored andcommitted
[FrameworkBundle] Fix a bug in the RedirectableUrlMatcher
1 parent f6b4f89 commit 66d0d3d

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableUrlMatcher.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Routing;
1313

14-
use Symfony\Component\Routing\Matcher\UrlMatcher;
15-
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcherInterface;
14+
use Symfony\Component\Routing\Matcher\RedirectableUrlMatcher as BaseMatcher;
1615

1716
/**
1817
* @author Fabien Potencier <fabien@symfony.com>
1918
*/
20-
class RedirectableUrlMatcher extends UrlMatcher implements RedirectableUrlMatcherInterface
19+
class RedirectableUrlMatcher extends BaseMatcher
2120
{
2221
/**
2322
* Redirects the user to another URL.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony framework.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Routing;
13+
14+
use Symfony\Bundle\FrameworkBundle\Routing\Router;
15+
use Symfony\Component\Routing\Route;
16+
use Symfony\Component\Routing\RouteCollection;
17+
use Symfony\Bundle\FrameworkBundle\Routing\RedirectableUrlMatcher;
18+
use Symfony\Component\Routing\RequestContext;
19+
20+
class RedirectableUrlMatcherTest extends \PHPUnit_Framework_TestCase
21+
{
22+
public function testRedirectWhenNoSlash()
23+
{
24+
$coll = new RouteCollection();
25+
$coll->add('foo', new Route('/foo/'));
26+
27+
$matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext());
28+
29+
$this->assertEquals(array(
30+
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction',
31+
'path' => '/foo/',
32+
'permanent' => true,
33+
'scheme' => null,
34+
'httpPort' => $context->getHttpPort(),
35+
'httpsPort' => $context->getHttpsPort(),
36+
'_route' => null,
37+
),
38+
$matcher->match('/foo')
39+
);
40+
}
41+
42+
public function testSchemeRedirect()
43+
{
44+
$coll = new RouteCollection();
45+
$coll->add('foo', new Route('/foo', array(), array('_scheme' => 'https')));
46+
47+
$matcher = new RedirectableUrlMatcher($coll, $context = new RequestContext());
48+
49+
$this->assertEquals(array(
50+
'_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction',
51+
'path' => '/foo',
52+
'permanent' => true,
53+
'scheme' => 'https',
54+
'httpPort' => $context->getHttpPort(),
55+
'httpsPort' => $context->getHttpsPort(),
56+
'_route' => 'foo',
57+
),
58+
$matcher->match('/foo')
59+
);
60+
}
61+
}

0 commit comments

Comments
 (0)