Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RawTest.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Framework\App\Response\HttpInterface as HttpResponseInterface;
11 
12 class RawTest extends \PHPUnit\Framework\TestCase
13 {
15  protected $raw;
16 
18  protected $response;
19 
22 
23  protected function setUp()
24  {
25  $this->objectManagerHelper = new ObjectManagerHelper($this);
26 
27  $this->response = $this->createMock(HttpResponseInterface::class);
28  $this->raw = $this->objectManagerHelper->getObject(\Magento\Framework\Controller\Result\Raw::class);
29  }
30 
31  public function testSetContents()
32  {
33  $content = '<content>test</content>';
34  $this->assertInstanceOf(\Magento\Framework\Controller\Result\Raw::class, $this->raw->setContents($content));
35  }
36 
37  public function testRender()
38  {
39  $content = '<content>test</content>';
40  $this->raw->setContents($content);
41  $this->response->expects($this->once())->method('setBody')->with($content);
42  $this->assertSame($this->raw, $this->raw->renderResult($this->response));
43  }
44 }