/** * @expectedException Symfony\Component\Routing\Exception\MissingMandatoryParametersException */ public function testGenerateI18nTranslatedWithoutLocale() { if (method_exists('Symfony\\Component\\Routing\\RouterInterface', 'getContext')) { $parentRouter = $this->getMock('Symfony\\Component\\Routing\\RouterInterface'); } else { // use the Router for Symfony 2.0 as it implements the needed methods but they were not in the interface $parentRouter = $this->getMockBuilder('Symfony\\Component\\Routing\\Router')->disableOriginalConstructor()->getMock(); } $context = $this->getMockBuilder('Symfony\\Component\\Routing\\RequestContext')->disableOriginalConstructor()->setMethods(array('getParameter', 'hasParameter'))->getMock(); $context->expects($this->once())->method('hasParameter')->with($this->equalTo('_locale'))->will($this->returnValue(false)); $parentRouter->expects($this->any())->method('getContext')->will($this->returnValue($context)); $router = new Router($parentRouter); $router->generate('test_route', array('foo' => 'bar', 'translate' => 'foo'), false); }