Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PageFactoryTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class PageFactoryTest extends \PHPUnit\Framework\TestCase
12 {
14  protected $pageFactory;
15 
17  protected $page;
18 
21 
23  protected $objectManagerMock;
24 
25  protected function setUp()
26  {
27  $this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
28  $this->objectManagerHelper = new ObjectManagerHelper($this);
29  $this->pageFactory = $this->objectManagerHelper->getObject(
30  \Magento\Framework\View\Result\PageFactory::class,
31  [
32  'objectManager' => $this->objectManagerMock
33  ]
34  );
35  $this->page = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class)
36  ->disableOriginalConstructor()
37  ->getMock();
38  }
39 
40  public function testCreate()
41  {
42  $this->objectManagerMock->expects($this->once())
43  ->method('create')
44  ->with(\Magento\Framework\View\Result\Page::class)
45  ->will($this->returnValue($this->page));
46  $this->assertSame($this->page, $this->pageFactory->create());
47  }
48 }