Exemplo n.º 1
0
 public function testRenderNamedSegment()
 {
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('view')->setActionName('name');
     $response = new Zend_Controller_Response_Cli();
     Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files');
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php';
     $controller = new ViewController($request, $response);
     $controller->nameAction();
     $this->assertContains('In the name view', $response->getBody('name'));
 }
Exemplo n.º 2
0
 public function testRenderUsingViewRenderer()
 {
     Zend_Controller_Action_HelperBroker::addHelper(new Zend_Controller_Action_Helper_ViewRenderer());
     $request = new Zend_Controller_Request_Http();
     $request->setControllerName('view')->setActionName('script');
     $response = new Zend_Controller_Response_Cli();
     Zend_Controller_Front::getInstance()->setControllerDirectory(dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files');
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'ViewController.php';
     $controller = new ViewController($request, $response);
     $controller->scriptAction();
     $this->assertContains('Inside custom/renderScript.php', $response->getBody());
 }
 /**
  * @group ZF-8041
  */
 public function testPostDispatchDoesNotRenderLayoutWhenResponseRedirected()
 {
     $front = Zend_Controller_Front::getInstance();
     $request = new Zend_Controller_Request_Simple();
     $response = new Zend_Controller_Response_Cli();
     $request->setDispatched(true);
     $response->setHttpResponseCode(302);
     $response->setBody('Application content');
     $front->setRequest($request)->setResponse($response);
     $layout = Zend_Layout::startMvc();
     $layout->setLayoutPath(dirname(__FILE__) . '/_files/layouts')->setLayout('plugin.phtml')->setMvcSuccessfulActionOnly(false)->disableInflector();
     $plugin = $front->getPlugin('Zend_Layout_Controller_Plugin_Layout');
     $plugin->setResponse($response);
     $plugin->postDispatch($request);
     $body = $response->getBody();
     $this->assertContains('Application content', $body);
     $this->assertNotContains('Site Layout', $body);
 }