forward() public method

public forward ( $controller, array $path = [], array $query = [] )
$path array
$query array
コード例 #1
0
 public function testForward()
 {
     $request = Request::create('/');
     $request->setLocale('fr');
     $request->setRequestFormat('xml');
     $requestStack = new RequestStack();
     $requestStack->push($request);
     $kernel = $this->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $kernel->expects($this->once())->method('handle')->will($this->returnCallback(function (Request $request) {
         return new Response($request->getRequestFormat() . '--' . $request->getLocale());
     }));
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $container->expects($this->at(0))->method('get')->will($this->returnValue($requestStack));
     $container->expects($this->at(1))->method('get')->will($this->returnValue($kernel));
     $controller = new TestController();
     $controller->setContainer($container);
     $response = $controller->forward('a_controller');
     $this->assertEquals('xml--fr', $response->getContent());
 }