Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
PageLayoutTest.php
Go to the documentation of this file.
1 <?php
7 
12 
13 class PageLayoutTest extends \PHPUnit\Framework\TestCase
14 {
18  protected $builderMock;
19 
24 
29 
33  protected $object;
34 
38  protected function setUp()
39  {
40  $this->objectManagerHelper = new ObjectManager($this);
41  $this->builderMock = $this->getMockBuilder(
42  \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface::class
43  )->disableOriginalConstructor()
44  ->setMethods(['getPageLayoutsConfig'])
45  ->getMock();
46  $this->pageLayoutConfigMock = $this->getMockBuilder(\Magento\Framework\View\PageLayout\Config::class)
47  ->disableOriginalConstructor()
48  ->setMethods(['getOptions'])
49  ->getMock();
50 
51  $this->builderMock->expects($this->any())
52  ->method('getPageLayoutsConfig')
53  ->willReturn($this->pageLayoutConfigMock);
54 
55  $this->object = $this->objectManagerHelper->getObject($this->getSourceClassName(), [
56  'pageLayoutBuilder' => $this->builderMock,
57  ]);
58  }
59 
63  protected function getSourceClassName()
64  {
65  return \Magento\Cms\Model\Page\Source\PageLayout::class;
66  }
67 
74  public function testToOptionArray(array $options, array $expected)
75  {
76  $this->pageLayoutConfigMock->expects($this->once())
77  ->method('getOptions')
78  ->willReturn($options);
79 
80  $this->assertSame($expected, $this->object->toOptionArray());
81  }
82 
86  public function getOptionsDataProvider()
87  {
88  return [
89  [
90  [],
91  [],
92  ],
93  [
94  ['testStatus' => 'testValue'],
95  [['label' => 'testValue', 'value' => 'testStatus']],
96  ],
97 
98  ];
99  }
100 }
testToOptionArray(array $options, array $expected)