Skip to content

Commit 8513ac9

Browse files
committed
[Routing] added working test case for issue symfony#5135
1 parent 2a637b1 commit 8513ac9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Routing/RouterTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@
1717

1818
class RoutingTest extends \PHPUnit_Framework_TestCase
1919
{
20+
public function testGenerateWithServiceParam()
21+
{
22+
$routes = new RouteCollection();
23+
24+
$routes->add('foo', new Route(
25+
' /{_locale}',
26+
array(
27+
'_locale' => '%locale%'
28+
),
29+
array(
30+
'_locale' => 'en|es',
31+
)
32+
));
33+
34+
$sc = $this->getServiceContainer($routes);
35+
36+
$sc->expects($this->at(1))->method('hasParameter')->will($this->returnValue(true));
37+
$sc->expects($this->at(2))->method('getParameter')->will($this->returnValue('es'));
38+
39+
$router = new Router($sc, 'foo');
40+
$route = $router->getRouteCollection()->get('foo');
41+
42+
$this->assertSame('/en', $router->generate('foo', array('_locale' => 'en')));
43+
$this->assertSame('/', $router->generate('foo', array('_locale' => 'es')));
44+
}
45+
2046
public function testDefaultsPlaceholders()
2147
{
2248
$routes = new RouteCollection();

0 commit comments

Comments
 (0)