/** * @param int|string $httpCode * @param string $headerName * @param string $headerValue * @param bool $replaceHeader * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setHttpResponseCodeCount * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $setHeaderCount * @dataProvider renderResultDataProvider */ public function testRenderResult($httpCode, $headerName, $headerValue, $replaceHeader, $setHttpResponseCodeCount, $setHeaderCount) { $layoutOutput = 'output'; $this->layout->expects($this->once())->method('getOutput')->will($this->returnValue($layoutOutput)); $this->request->expects($this->once())->method('getFullActionName')->will($this->returnValue('Module_Controller_Action')); $this->eventManager->expects($this->exactly(2))->method('dispatch')->withConsecutive(['layout_render_before'], ['layout_render_before_Module_Controller_Action']); $this->translateInline->expects($this->once())->method('processResponseBody')->with($layoutOutput)->willReturnSelf(); /** @var \Magento\Framework\App\Response\Http|\PHPUnit_Framework_MockObject_MockObject $response */ $response = $this->getMock('Magento\\Framework\\App\\Response\\Http', [], [], '', false); $response->expects($setHttpResponseCodeCount)->method('setHttpResponseCode')->with($httpCode); $response->expects($setHeaderCount)->method('setHeader')->with($headerName, $headerValue, $replaceHeader); $response->expects($this->once())->method('appendBody')->with($layoutOutput); $this->resultLayout->setHttpResponseCode($httpCode); if ($headerName && $headerValue) { $this->resultLayout->setHeader($headerName, $headerValue, $replaceHeader); } $this->resultLayout->renderResult($response); }
/** * {@inheritdoc} */ public function setHeader($name, $value, $replace = false) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setHeader'); if (!$pluginInfo) { return parent::setHeader($name, $value, $replace); } else { return $this->___callPlugins('setHeader', func_get_args(), $pluginInfo); } }