public function testPreDispatchNonWhitelistedAction() { $this->request->setModuleName('default')->setControllerName('foo')->setActionName('home'); $this->plugin->preDispatch($this->request); $this->assertTrue($this->response->isRedirect()); $responseHeaders = $this->response->getHeaders(); $this->assertEquals('/user/login', $responseHeaders[0]['value']); }
/** * Send response to browser with json content type */ public function sendResponse() { $this->_response = Mage::app()->getResponse(); //check redirect if ($this->_response->isRedirect()) { $headers = $this->_response->getHeaders(); $redirect = ''; foreach ($headers as $header) { if ("Location" == $header["name"]) { $redirect = $header["value"]; break; } } if ($redirect) { $this->setRedirect($redirect); } } $this->_response->clearHeaders(); $this->_response->setHeader('Content-Type', 'application/json'); $this->_response->clearBody(); $this->_response->setBody($this->toJson()); $this->_response->sendResponse(); exit; }
/** * Asserts that the response is a redirect. */ public function redirects() { $message = 'Response does not perform a redirect.'; PHPUnit_Framework_Assert::assertTrue($this->response->isRedirect(), $message); }