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
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Setup\Test\Unit\Fixtures;
use Magento\Setup\Fixtures\ConfigsApplyFixture;
class ConfigsApplyFixtureTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Setup\Fixtures\FixtureModel
*/
private $fixtureModelMock;
/**
* @var \Magento\Setup\Fixtures\ConfigsApplyFixture
*/
private $model;
public function setUp()
{
$this->fixtureModelMock = $this->createMock(\Magento\Setup\Fixtures\FixtureModel::class);
$this->model = new ConfigsApplyFixture($this->fixtureModelMock);
}
public function testExecute()
{
$cacheMock = $this->createMock(\Magento\Framework\App\Cache::class);
$valueMock = $this->createMock(\Magento\Framework\App\Config::class);
$configMock = $this->createMock(\Magento\Config\App\Config\Type\System::class);
$objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
$objectManagerMock
->method('get')
->willReturnMap([
[\Magento\Framework\App\CacheInterface::class, $cacheMock],
[\Magento\Config\App\Config\Type\System::class, $configMock]
]);
$this->fixtureModelMock
->expects($this->once())
->method('getValue')
->will($this->returnValue(['config' => $valueMock]));
$this->fixtureModelMock
->method('getObjectManager')
->will($this->returnValue($objectManagerMock));
$cacheMock->method('clean');
$configMock->method('clean');
$this->model->execute();
}
public function testNoFixtureConfigValue()
{
$configMock = $this->getMockBuilder(\Magento\Framework\App\Config\ValueInterface::class)
->setMethods(['save'])
->getMockForAbstractClass();
$configMock->expects($this->never())->method('save');
$objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
$objectManagerMock->expects($this->never())
->method('create')
->willReturn($configMock);
$this->fixtureModelMock
->expects($this->never())
->method('getObjectManager')
->will($this->returnValue($objectManagerMock));
$this->fixtureModelMock
->expects($this->once())
->method('getValue')
->willReturn(false);
$this->model->execute();
}
public function testGetActionTitle()
{
$this->assertSame('Config Changes', $this->model->getActionTitle());
}
public function testIntroduceParamLabels()
{
$this->assertSame([], $this->model->introduceParamLabels());
}
}