Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function renderResult(\Magento\Framework\App\ResponseInterface $response)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'renderResult');
     if (!$pluginInfo) {
         return parent::renderResult($response);
     } else {
         return $this->___callPlugins('renderResult', func_get_args(), $pluginInfo);
     }
 }
Пример #2
0
 /**
  * @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);
 }
Пример #3
0
 /**
  * @param ResponseInterface $response
  * @return $this
  */
 public function renderResult(ResponseInterface $response)
 {
     if ($this->getConfig()->getPageLayout()) {
         $layout = $this->getLayout();
         $config = $this->getConfig();
         $this->assign('headContent', $layout->getBlock('head')->toHtml());
         $this->addDefaultBodyClasses();
         $this->assign('bodyClasses', $config->getElementAttribute($config::ELEMENT_TYPE_BODY, 'classes'));
         $this->assign('bodyAttributes', $config->getElementAttribute($config::ELEMENT_TYPE_BODY, 'attributes'));
         $this->assign('htmlAttributes', $config->getElementAttribute($config::ELEMENT_TYPE_HTML, 'attributes'));
         $output = $layout->getOutput();
         $this->translateInline->processResponseBody($output);
         $this->assign('layoutContent', $output);
         $response->appendBody($this->toHtml());
     } else {
         parent::renderResult($response);
     }
     return $this;
 }