/** * Test for getHeader method. Validation for attempt to get not existing header * * @covers \Magento\Framework\App\Response\Http::getHeader */ public function testGetHeaderNotExists() { $cookieMock = $this->getMock('\\Magento\\Framework\\Stdlib\\Cookie', array(), array(), '', false); $contextMock = $this->getMock('Magento\\Framework\\App\\Http\\Context', array(), array(), '', false); $response = new \Magento\Framework\App\Response\Http($cookieMock, $contextMock); $response->headersSentThrowsException = false; $response->setHeader('Name', 'value', true); $this->assertFalse($response->getHeader('Wrong name')); }
public function testSetAuthenticationFailed() { $request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', array(), array(), '', false); $cookieMock = $this->getMock('Magento\\Framework\\Stdlib\\Cookie', array(), array(), '', false); $contextMock = $this->getMock('Magento\\Framework\\App\\Http\\Context', array(), array(), '', false); $response = new \Magento\Framework\App\Response\Http($cookieMock, $contextMock); $authentication = new \Magento\Framework\HTTP\Authentication($request, $response); $realm = uniqid(); $response->headersSentThrowsException = false; $authentication->setAuthenticationFailed($realm); $headers = $response->getHeaders(); $this->assertArrayHasKey(0, $headers); $this->assertEquals('401 Unauthorized', $headers[0]['value']); $this->assertArrayHasKey(1, $headers); $this->assertContains('realm="' . $realm . '"', $headers[1]['value']); $this->assertContains('401', $response->getBody()); }
/** * Process report * * @return \Magento\Framework\App\Response\Http */ public function processReport() { $this->pageTitle = 'There has been an error processing your request'; $this->_response->setHttpResponseCode(503); $this->showErrorMsg = false; $this->showSentMsg = false; $this->showSendForm = false; $this->reportAction = $this->_config->action; $this->_setReportUrl(); if ($this->reportAction == 'email') { $this->showSendForm = true; $this->sendReport(); } $this->_response->setBody($this->_renderPage('report.phtml')); return $this->_response; }