1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Cms\Test\Unit\Model\Block\Source;
use Magento\Cms\Model\Block;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
class IsActiveTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Block|\PHPUnit_Framework_MockObject_MockObject
*/
protected $cmsBlockMock;
/**
* @var ObjectManager
*/
protected $objectManagerHelper;
/**
* @var Block\Source\IsActive
*/
protected $object;
/**
* {@inheritdoc}
*/
protected function setUp()
{
$this->objectManagerHelper = new ObjectManager($this);
$this->cmsBlockMock = $this->getMockBuilder(\Magento\Cms\Model\Block::class)
->disableOriginalConstructor()
->setMethods(['getAvailableStatuses'])
->getMock();
$this->object = $this->objectManagerHelper->getObject($this->getSourceClassName(), [
'cmsBlock' => $this->cmsBlockMock,
]);
}
/**
* @return string
*/
protected function getSourceClassName()
{
return \Magento\Cms\Model\Block\Source\IsActive::class;
}
/**
* @param array $availableStatuses
* @param array $expected
* @return void
* @dataProvider getAvailableStatusesDataProvider
*/
public function testToOptionArray(array $availableStatuses, array $expected)
{
$this->cmsBlockMock->expects($this->once())
->method('getAvailableStatuses')
->willReturn($availableStatuses);
$this->assertSame($expected, $this->object->toOptionArray());
}
/**
* @return array
*/
public function getAvailableStatusesDataProvider()
{
return [
[
[],
[],
],
[
['testStatus' => 'testValue'],
[['label' => 'testValue', 'value' => 'testStatus']],
],
];
}
}