コード例 #1
0
    /**
     * Set up redirector
     *
     * Creates request, response, and action controller objects; sets action
     * controller in redirector, and sets exit to false.
     *
     * Also resets the front controller instance.
     */
    public function setUp()
    {
        $front = Controller\Front::getInstance();
        $front->resetInstance();
        $broker = $front->getHelperBroker();

        $this->redirector = new \Zend\Controller\Action\Helper\Redirector();
        $this->redirector->setBroker($broker);

        $this->router     = $front->getRouter();
        $this->request    = new \Zend\Controller\Request\Http();
        $this->response   = new \Zend\Controller\Response\Http();
        $this->controller = new TestController(
            $this->request,
            $this->response,
            array()
        );

        // Add default routes
        $this->router->addDefaultRoutes();

        // do this so setting headers does not throw exceptions
        $this->response->headersSentThrowsException = false;

        $this->redirector->setExit(false)
                         ->setActionController($this->controller);
        $this->_server = $_SERVER;
    }