Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
HtmlContentFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
13 
14 class HtmlContentFactoryTest extends \PHPUnit\Framework\TestCase
15 {
19  private $layout;
20 
24  private $block;
25 
29  private $context;
30 
34  private $htmlContentFactory;
35 
36  public function setUp()
37  {
38  $this->layout = $this->getMockBuilder(Layout::class)
39  ->disableOriginalConstructor()
40  ->getMock();
41  $this->block = $this->getMockBuilder(AbstractBlock::class)
42  ->disableOriginalConstructor()
43  ->getMockForAbstractClass();
44  $this->context = $this->getMockBuilder(ContextInterface::class)
45  ->disableOriginalConstructor()
46  ->getMockForAbstractClass();
47 
48  $this->htmlContentFactory = new HtmlContentFactory();
49  }
50 
51  public function testCreate()
52  {
53  $blockName = 'blockName';
54  $bundleComponents[ManagerInterface::COMPONENT_ARGUMENTS_KEY]['block']['name'] = $blockName;
55  $this->layout->expects($this->once())
56  ->method('getBlock')
57  ->with($blockName)
58  ->willReturn($this->block);
59  $this->context->expects($this->once())
60  ->method('getPageLayout')
61  ->willReturn($this->layout);
62  $this->assertTrue(
63  $this->htmlContentFactory->create(
64  $bundleComponents,
65  [
66  'context' => $this->context
67  ]
68  )
69  );
70  $this->assertEquals($this->block, $bundleComponents[ManagerInterface::COMPONENT_ARGUMENTS_KEY]['block']);
71  }
72 }