Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 762114a

Browse files
committed
test situation when content has routes but none matching the preferred locale. fix symfony#62
1 parent 804f22a commit 762114a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Tests/Routing/ContentAwareGeneratorTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function testGenerateRouteMultilang()
120120
$this->assertEquals('result_url', $this->generator->generate($route_en, array('_locale' => 'de')));
121121
}
122122

123-
public function testGenerateRouteMultilangNomatch()
123+
public function testGenerateRouteMultilangLocaleNomatch()
124124
{
125125
$route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile', 'getRouteContent'));
126126
$route_en->setLocale('en');
@@ -228,6 +228,28 @@ public function testGenerateDocumentMultilang()
228228
$this->assertEquals('result_url', $this->generator->generate($this->contentDocument, array('_locale' => 'de')));
229229
}
230230

231+
public function testGenerateDocumentMultilangLocaleNomatch()
232+
{
233+
$route_en = $this->buildMock('Symfony\\Cmf\\Component\\Routing\\Tests\\Routing\\RouteMock', array('getDefaults', 'compile'));
234+
$route_en->setLocale('en');
235+
$route_de = $this->routeDocument;
236+
$route_de->setLocale('de');
237+
238+
$this->contentDocument->expects($this->once())
239+
->method('getRoutes')
240+
->will($this->returnValue(array($route_en, $route_de)))
241+
;
242+
$route_en->expects($this->once())
243+
->method('compile')
244+
->will($this->returnValue($this->routeCompiled))
245+
;
246+
$route_de->expects($this->never())
247+
->method('compile')
248+
;
249+
250+
$this->assertEquals('result_url', $this->generator->generate($this->contentDocument, array('_locale' => 'fr')));
251+
}
252+
231253
/**
232254
* @expectedException Symfony\Component\Routing\Exception\RouteNotFoundException
233255
*/

0 commit comments

Comments
 (0)