Exemple #1
0
 public function testRenderUsingViewRenderer()
 {
     HelperBroker::addHelper(new Helper\ViewRenderer());
     $request = new Request\Http();
     $request->setControllerName('view')->setActionName('script');
     $response = new Response\Cli();
     Controller\Front::getInstance()->setControllerDirectory(__DIR__ . DIRECTORY_SEPARATOR . '_files');
     $controller = new \ViewController($request, $response);
     $controller->scriptAction();
     $this->assertContains('Inside custom/renderScript.php', $response->getBody());
 }
Exemple #2
0
    /**
     * @group ZF-8041
     */
    public function testPostDispatchDoesNotRenderLayoutWhenResponseRedirected()
    {
        $front    = Controller\Front::getInstance();
        $request  = new Request\Simple();
        $response = new Response\Cli();

        $request->setDispatched(true);
        $response->setHttpResponseCode(302);
        $response->setBody('Application content');
        $front->setRequest($request)
              ->setResponse($response);

        $layout = Layout\Layout::startMvc();
        $layout->setLayoutPath(__DIR__ . '/_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);
    }