public function setUp() { $this->request = new \Symfony\Component\HttpFoundation\Request(); $storage = new \Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage(); $session = new \Symfony\Component\HttpFoundation\Session\Session($storage); $this->request->setSession($session); $this->request->initialize(); $this->response = new \Symfony\Component\HttpFoundation\Response(); $this->moduleConfig = new \Phruts\Config\ModuleConfig(''); $actionConfig = new \Phruts\Config\ActionConfig(); $actionConfig->setPath('/default'); $actionConfig->setType('\\Phruts\\Actions\\ForwardAction'); $this->moduleConfig->addActionConfig($actionConfig); $controllerConfig = new \Phruts\Config\ControllerConfig(); $controllerConfig->setLocale('fr'); $controllerConfig->setContentType('application/x-javascript'); $this->moduleConfig->setControllerConfig($controllerConfig); // Add a default action mapping $this->actionConfig1 = new ActionMapping(); $this->actionConfig1->setPath('/mypath'); $this->actionConfig1->setType('\\Phruts\\Action\\Action'); $forwardConfig = new ForwardConfig(); $forwardConfig->setName('success'); $forwardConfig->setPath('success.html.twig'); $this->actionConfig1->setModuleConfig($this->moduleConfig); $this->moduleConfig->addActionConfig($this->actionConfig1); // $this->application = new \Silex\Application(); $this->application = $this->getMock('\\Silex\\Application', array('handle')); $this->application->expects($this->any())->method('handle')->willReturn(new Response()); $this->actionKernel = new \Phruts\Action\ActionKernel($this->application); $this->requestProcessor = new \Phruts\Action\RequestProcessor(); $this->requestProcessor->init($this->actionKernel, $this->moduleConfig); }
public function testGetInputForward() { // Input forward $this->actionMapping->setInput('aPath'); $forward = $this->actionMapping->getInputForward(); $this->assertNotEmpty($forward); $this->assertEquals('aPath', $forward->getPath()); // Controller based input forward $controllerConfig = new \Phruts\Config\ControllerConfig(); $controllerConfig->setInputForward(true); $this->actionMapping->setInput('path1'); $this->moduleConfig->setControllerConfig($controllerConfig); $forward = $this->actionMapping->getInputForward(); $this->assertNotEmpty($forward); $this->assertEquals('path1', $forward->getName()); }