public function testCorrectViewHelperPathShouldBePropagatedWhenSubControllerInvoked() { require_once $this->basePath . '/_files/modules/foo/controllers/Admin/IndexController.php'; $this->request->setModuleName('foo')->setControllerName('admin_index')->setActionName('use-helper'); $controller = new \Foo\Admin\IndexController($this->request, $this->response, array()); $this->helper->render(); $body = $this->response->getBody(); $this->assertContains('FooUseHelper invoked', $body, 'Received ' . $body); }
public function testPostDispatchQuitsWithFalseUserErrorHandlerParam() { $front = Controller\Front::getInstance(); $front->resetInstance(); $front->setParam('noErrorHandler', true); $this->response->setException(new Dispatcher\Exception('Testing controller exception')); $this->request->setModuleName('foo')->setControllerName('bar')->setActionName('baz'); $this->plugin->postDispatch($this->request); $this->assertNull($this->request->getParam('error_handler')); }
/** * @group ZF-4318 */ public function testServerVariableHttpsToOffDoesNotBuildHttpsUrl() { // Set Preconditions from Issue: $_SERVER['HTTPS'] = "off"; $_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['SERVER_PORT'] = 80; $this->redirector->setUseAbsoluteUri(true); $this->request->setModuleName('admin')->setControllerName('class')->setActionName('view'); $this->redirector->gotoUrl('/bar/baz'); $test = $this->redirector->getRedirectUrl(); $this->assertNotContains('https://', $test); $this->assertEquals('http://localhost/bar/baz', $test); }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { $front = Zend_Controller_Front::getInstance(); if (!$front->getPlugin('Zend_Controller_Plugin_ErrorHandler') instanceof Zend_Controller_Plugin_ErrorHandler) { return; } $error = $front->getPlugin('Zend_Controller_Plugin_ErrorHandler'); $testRequest = new Zend_Controller_Request_HTTP(); $testRequest->setModuleName($request->getModuleName())->setControllerName($error->getErrorHandlerController())->setActionName($error->getErrorHandlerAction()); if ($front->getDispatcher()->isDispatchable($testRequest)) { $error->setErrorHandlerModule($request->getModuleName()); } }
public function routeShutdown(Zend_Controller_Request_Abstract $request) { $front = Zend_Controller_Front::getInstance(); //If the ErrorHandler plugin is not registered, bail out if (!$front->getPlugin('Zend_Controller_Plugin_ErrorHandler') instanceof Zend_Controller_Plugin_ErrorHandler) { return; } $error = $front->getPlugin('Zend_Controller_Plugin_ErrorHandler'); //Generate a test request to use to determine if the error controller in our module exists $testRequest = new Zend_Controller_Request_HTTP(); $testRequest->setModuleName($request->getModuleName())->setControllerName($error->getErrorHandlerController())->setActionName($error->getErrorHandlerAction()); //Does the controller even exist? if ($front->getDispatcher()->isDispatchable($testRequest)) { $error->setErrorHandlerModule($request->getModuleName()); } }