/**
     * Sets up the fixture, for example, open a network connection.
     * This method is called before a test is executed.
     *
     * @return void
     */
    public function setUp()
    {
        \Zend\Layout\Layout::resetMvcInstance();

        $this->front = Controller\Front::getInstance();
        $this->front->resetInstance();
        $this->front->addModuleDirectory(__DIR__ . '/../../_files/modules');
        $this->broker = $this->front->getHelperBroker();

        $this->layout = Layout\Layout::startMvc();

        $this->helper = new Helper\ContextSwitch();
        $this->broker->register('contextswitch', $this->helper);

        $this->request = new \Zend\Controller\Request\Http();
        $this->response = new \Zend\Controller\Response\Cli();

        $this->front->setRequest($this->request)
                    ->setResponse($this->response)
                    ->addControllerDirectory(__DIR__);

        $this->view = new \Zend\View\PhpRenderer();
        $this->viewRenderer = $this->broker->load('viewRenderer');
        $this->viewRenderer->setView($this->view);

        $this->controller = new ContextSwitchTestController(
            $this->request,
            $this->response,
            array()
        );
        $this->controller->setHelperBroker($this->broker);
        $this->controller->setupContexts();
        $this->helper->setActionController($this->controller);
    }
Exemple #2
0
    /**
     * Sets up the fixture, for example, open a network connection.
     * This method is called before a test is executed.
     *
     * @return void
     */
    public function setUp()
    {
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
            unset($_SERVER['HTTP_X_REQUESTED_WITH']);
        }

        \Zend\Layout\Layout::resetMvcInstance();

        $this->front = \Zend\Controller\Front::getInstance();
        $this->front->resetInstance();
        $this->front->addModuleDirectory(__DIR__ . '/../../_files/modules');
        $this->broker = $this->front->getHelperBroker();

        $this->layout = Layout\Layout::startMvc();

        $this->helper = new \Zend\Controller\Action\Helper\AjaxContext();

        $this->request = new \Zend\Controller\Request\Http();
        $this->response = new \Zend\Controller\Response\Cli();

        $this->front->setRequest($this->request)->setResponse($this->response);
        $this->view = new \Zend\View\PhpRenderer();
        $this->viewRenderer = $this->broker->load('viewRenderer');
        $this->viewRenderer->setView($this->view);

        $this->controller = new AjaxContextTestController(
            $this->request,
            $this->response,
            array()
        );
        $this->helper->setActionController($this->controller);
    }
Exemple #3
0
 /**
  * Retrieve layout object
  *
  * @return \Zend\Layout\Layout
  */
 public function getLayout()
 {
     if (null === $this->_layout) {
         $this->_layout = \Zend\Layout\Layout::startMvc($this->getOptions());
     }
     return $this->_layout;
 }
Exemple #4
0
 public function appBootstrap()
 {
     $this->frontController->setControllerDirectory(__DIR__ . '/_files/functional-test-app/controllers/');
     // create an instance of the ErrorHandler so we can make sure it will point to our specially named ErrorController
     $plugin = new \Zend\Controller\Plugin\ErrorHandler();
     $plugin->setErrorHandlerController('zend-layout-functional-test-error')->setErrorHandlerAction('error');
     $this->frontController->registerPlugin($plugin, 100);
     \Zend\Layout\Layout::startMvc(__DIR__ . '/_files/functional-test-app/layouts/');
 }
Exemple #5
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     Layout::resetMvcInstance();
     $this->request = new HTTPRequest();
     $this->response = new CLIResponse();
     $this->front = FrontController::getInstance();
     $this->front->resetInstance();
     $this->front->setRequest($this->request)->setResponse($this->response);
     $this->broker = $this->front->getHelperBroker();
     $this->viewRenderer = $this->broker->load('viewRenderer');
     $this->layout = Layout::startMvc();
 }
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     Layout::resetMvcInstance();
     HelperBroker::resetHelpers();
     HelperBroker::setPluginLoader(null);
     $this->request = new HTTPRequest();
     $this->response = new CLIResponse();
     $this->front = FrontController::getInstance();
     $this->front->resetInstance();
     $this->front->setRequest($this->request)->setResponse($this->response);
     $this->viewRenderer = HelperBroker::getStaticHelper('viewRenderer');
     $this->layout = Layout::startMvc();
 }
Exemple #7
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->markTestSkipped('Skipped until DOJO is converted to Zend\\Dojo');
     \Zend\Layout\Layout::resetMvcInstance();
     HelperBroker\HelperBroker::resetHelpers();
     HelperBroker\HelperBroker::setPluginLoader(null);
     $this->request = new \Zend\Controller\Request\HTTP();
     $this->response = new \Zend\Controller\Response\Cli();
     $this->front = \Zend\Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->front->setRequest($this->request)->setResponse($this->response);
     $this->viewRenderer = HelperBroker\HelperBroker::getStaticHelper('viewRenderer');
     $this->layout = Layout\Layout::startMvc();
 }
Exemple #8
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     \Zend\Layout\Layout::resetMvcInstance();
     HelperBroker\HelperBroker::resetHelpers();
     $this->front = Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->front->addModuleDirectory(dirname(__FILE__) . '/../../_files/modules');
     $this->layout = Layout\Layout::startMvc();
     $this->helper = new Helper\ContextSwitch();
     HelperBroker\HelperBroker::addHelper($this->helper);
     $this->request = new \Zend\Controller\Request\HTTP();
     $this->response = new \Zend\Controller\Response\Cli();
     $this->front->setRequest($this->request)->setResponse($this->response)->addControllerDirectory(dirname(__FILE__));
     $this->view = new \Zend\View\View();
     $this->viewRenderer = HelperBroker\HelperBroker::getStaticHelper('viewRenderer');
     $this->viewRenderer->setView($this->view);
     $this->controller = new ContextSwitchTestController($this->request, $this->response, array());
     $this->controller->setupContexts();
     $this->helper->setActionController($this->controller);
 }
Exemple #9
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
         unset($_SERVER['HTTP_X_REQUESTED_WITH']);
     }
     \Zend\Layout\Layout::resetMvcInstance();
     HelperBroker\HelperBroker::resetHelpers();
     HelperBroker\HelperBroker::addPrefix('Zend\\Controller\\Action\\Helper');
     $this->front = \Zend\Controller\Front::getInstance();
     $this->front->resetInstance();
     $this->front->addModuleDirectory(dirname(__FILE__) . '/../../_files/modules');
     $this->layout = Layout\Layout::startMvc();
     $this->helper = new \Zend\Controller\Action\Helper\AjaxContext();
     $this->request = new \Zend\Controller\Request\HTTP();
     $this->response = new \Zend\Controller\Response\Cli();
     $this->front->setRequest($this->request)->setResponse($this->response);
     $this->view = new \Zend\View\View();
     $this->view->addHelperPath(dirname(__FILE__) . '/../../../../../library/Zend/View/Helper/');
     $this->viewRenderer = HelperBroker\HelperBroker::getStaticHelper('viewRenderer');
     $this->viewRenderer->setView($this->view);
     $this->controller = new AjaxContextTestController($this->request, $this->response, array());
     $this->helper->setActionController($this->controller);
 }
Exemple #10
0
 public function testHelperProxiesToLayoutObjectMethods()
 {
     $layout = Layout\Layout::startMvc();
     $helper = new Helper\Layout();
     $helper->setOptions(array('layout' => 'foo.phtml', 'layoutPath' => __DIR__ . '/_files/layouts', 'contentKey' => 'foo'));
     $this->assertEquals('foo.phtml', $helper->getLayout());
     $this->assertEquals(__DIR__ . '/_files/layouts', $helper->getLayoutPath());
     $this->assertEquals('foo', $helper->getContentKey());
 }
Exemple #11
0
 /**
  * @group ZF-5152
  */
 public function testCallingStartMvcTwiceDoesntGenerateAnyUnexpectedBehavior()
 {
     Layout\Layout::startMvc('/some/path');
     $this->assertEquals(Layout\Layout::getMvcInstance()->getLayoutPath(), '/some/path');
     Layout\Layout::startMvc('/some/other/path');
     $this->assertEquals(Layout\Layout::getMvcInstance()->getLayoutPath(), '/some/other/path');
     $this->assertTrue(Layout\Layout::getMvcInstance()->isEnabled());
 }
Exemple #12
0
 public function testJsonHelperDoesNotDisableLayoutsWhenKeepLayoutFlagTrue()
 {
     $layout = Layout\Layout::startMvc();
     $this->assertTrue($layout->isEnabled());
     $data = $this->helper->direct(array('foobar'), true);
     $this->assertTrue($layout->isEnabled());
 }
Exemple #13
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);
    }
Exemple #14
0
 public function testCanKeepLayoutsWhenUsingDirect()
 {
     $layout = Layout\Layout::startMvc();
     $data = $this->helper->direct(array('foobar'), false, true);
     $this->assertTrue($layout->isEnabled());
     $this->assertFalse($this->viewRenderer->getNoRender());
 }
Exemple #15
0
 public function testHelperMethodFetchesLayoutObject()
 {
     $layout = Layout\Layout::startMvc();
     $helper = new Helper\Layout();
     $received = $helper->direct();
     $this->assertSame($layout, $received);
 }