Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RenderFactoryTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class RenderFactoryTest extends \PHPUnit\Framework\TestCase
12 {
14  protected $renderFactory;
15 
18 
20  protected $objectManagerMock;
21 
22  protected function setUp()
23  {
24  $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
25 
26  $this->objectManagerHelper = new ObjectManagerHelper($this);
27  $this->renderFactory = $this->objectManagerHelper->getObject(
28  \Magento\Framework\View\Render\RenderFactory::class,
29  [
30  'objectManager' => $this->objectManagerMock
31  ]
32  );
33  }
34 
35  public function testGet()
36  {
37  $instance = \Magento\Framework\View\RenderInterface::class;
38  $renderMock = $this->createMock($instance);
39  $data = 'RenderInterface';
40  $this->objectManagerMock->expects($this->once())
41  ->method('get')
42  ->with($this->equalTo(\Magento\Framework\View\Render\RenderInterface::class))
43  ->will($this->returnValue($renderMock));
44  $this->assertInstanceOf($instance, $this->renderFactory->get($data));
45  }
46 
51  public function testGetException()
52  {
53  $this->objectManagerMock->expects($this->once())
54  ->method('get')
55  ->with($this->equalTo(\Magento\Framework\View\Render\RenderInterface::class))
56  ->will($this->returnValue(new \stdClass()));
57  $this->renderFactory->get('RenderInterface');
58  }
59 }