public function testRouterResetWithParentRequestOnKernelFinishRequest() { // the request context is updated $context = $this->getMock('Symfony\\Component\\Routing\\RequestContext'); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $router = $this->getMock('Symfony\\Component\\Routing\\Router', array('getContext'), array(), '', false); $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $parentRequest = Request::create('/'); $parentRequest->setLocale('es'); $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); $event = $this->getMock('Symfony\\Component\\HttpKernel\\Event\\FinishRequestEvent', array(), array(), '', false); $listener = new LocaleListener('fr', $router, $this->requestStack); $listener->onKernelFinishRequest($event); }
public function testRouterResetWithParentRequestOnKernelFinishRequest() { // the request context is updated $context = $this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock(); $context->expects($this->once())->method('setParameter')->with('_locale', 'es'); $router = $this->getMockBuilder('Symfony\Component\Routing\Router')->setMethods(array('getContext'))->disableOriginalConstructor()->getMock(); $router->expects($this->once())->method('getContext')->will($this->returnValue($context)); $parentRequest = Request::create('/'); $parentRequest->setLocale('es'); $this->requestStack->expects($this->once())->method('getParentRequest')->will($this->returnValue($parentRequest)); $event = $this->getMockBuilder('Symfony\Component\HttpKernel\Event\FinishRequestEvent')->disableOriginalConstructor()->getMock(); $listener = new LocaleListener($this->requestStack, 'fr', $router); $listener->onKernelFinishRequest($event); }