public function setUp() { $savePath = ini_get('session.save_path'); if (strpos($savePath, ';')) { $savePath = explode(';', $savePath); $savePath = array_pop($savePath); } if (empty($savePath)) { $this->markTestSkipped('Cannot test FlashMessenger due to unavailable session save path'); } if (headers_sent()) { $this->markTestSkipped('Cannot test FlashMessenger: cannot start session because headers already sent'); } \Zend\Session\Manager::start(); $this->front = \Zend\Controller\Front::getInstance(); $this->front->resetInstance(); $this->front->setControllerDirectory(dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . '_files'); $this->front->returnResponse(true); $this->request = new \Zend\Controller\Request\Http(); $this->request->setControllerName('helper-flash-messenger'); $this->response = new \Zend\Controller\Response\Cli(); $this->controller = new \HelperFlashMessengerController($this->request, $this->response, array()); $this->helper = new \Zend\Controller\Action\Helper\FlashMessenger($this->controller); }
public function test_marshall_PUT_body_as_params() { $this->request->setMethod('PUT'); $this->request->setRawBody('param1=value1¶m2=value2'); $this->plugin->preDispatch($this->request); $this->assertEquals('value1', $this->request->getParam('param1')); $this->assertEquals('value2', $this->request->getParam('param2')); }
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()); } }
/** * @group ZF-5107 */ public function testGetParamsShouldHonorParamSourcesSetting() { $_GET = array('foo' => 'bar'); $_POST = array('foo' => 'baz'); $this->_request->setParamSources(array('_POST')); $params = $this->_request->getParams(); $this->assertEquals(array('foo' => 'baz'), $params); }
public function testCorrectViewHelperPathShouldBePropagatedWhenSubControllerInvokedInDefaultModule() { require_once $this->basePath . '/_files/modules/application/controllers/Admin/HelperController.php'; $this->request->setControllerName('admin_helper')->setActionName('render'); $controller = new \Admin\HelperController($this->request, $this->response, array()); $this->helper->render(); $body = $this->response->getBody(); $this->assertContains('SampleZfHelper 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); }