Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IsActiveTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class IsActiveTest extends \PHPUnit\Framework\TestCase
12 {
16  protected $cmsBlockMock;
17 
22 
26  protected $object;
27 
31  protected function setUp()
32  {
33  $this->objectManagerHelper = new ObjectManager($this);
34  $this->cmsBlockMock = $this->getMockBuilder(\Magento\Cms\Model\Block::class)
35  ->disableOriginalConstructor()
36  ->setMethods(['getAvailableStatuses'])
37  ->getMock();
38 
39  $this->object = $this->objectManagerHelper->getObject($this->getSourceClassName(), [
40  'cmsBlock' => $this->cmsBlockMock,
41  ]);
42  }
43 
47  protected function getSourceClassName()
48  {
49  return \Magento\Cms\Model\Block\Source\IsActive::class;
50  }
51 
58  public function testToOptionArray(array $availableStatuses, array $expected)
59  {
60  $this->cmsBlockMock->expects($this->once())
61  ->method('getAvailableStatuses')
62  ->willReturn($availableStatuses);
63 
64  $this->assertSame($expected, $this->object->toOptionArray());
65  }
66 
71  {
72  return [
73  [
74  [],
75  [],
76  ],
77  [
78  ['testStatus' => 'testValue'],
79  [['label' => 'testValue', 'value' => 'testStatus']],
80  ],
81  ];
82  }
83 }
testToOptionArray(array $availableStatuses, array $expected)