Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigsApplyFixtureTest.php
Go to the documentation of this file.
1 <?php
8 
10 
11 class ConfigsApplyFixtureTest extends \PHPUnit\Framework\TestCase
12 {
13 
17  private $fixtureModelMock;
18 
22  private $model;
23 
24  public function setUp()
25  {
26  $this->fixtureModelMock = $this->createMock(\Magento\Setup\Fixtures\FixtureModel::class);
27 
28  $this->model = new ConfigsApplyFixture($this->fixtureModelMock);
29  }
30 
31  public function testExecute()
32  {
33  $cacheMock = $this->createMock(\Magento\Framework\App\Cache::class);
34 
35  $valueMock = $this->createMock(\Magento\Framework\App\Config::class);
36  $configMock = $this->createMock(\Magento\Config\App\Config\Type\System::class);
37 
38  $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
39  $objectManagerMock
40  ->method('get')
41  ->willReturnMap([
42  [\Magento\Framework\App\CacheInterface::class, $cacheMock],
43  [\Magento\Config\App\Config\Type\System::class, $configMock]
44  ]);
45 
46  $this->fixtureModelMock
47  ->expects($this->once())
48  ->method('getValue')
49  ->will($this->returnValue(['config' => $valueMock]));
50  $this->fixtureModelMock
51  ->method('getObjectManager')
52  ->will($this->returnValue($objectManagerMock));
53 
54  $cacheMock->method('clean');
55  $configMock->method('clean');
56 
57  $this->model->execute();
58  }
59 
60  public function testNoFixtureConfigValue()
61  {
62  $configMock = $this->getMockBuilder(\Magento\Framework\App\Config\ValueInterface::class)
63  ->setMethods(['save'])
64  ->getMockForAbstractClass();
65  $configMock->expects($this->never())->method('save');
66 
67  $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
68  $objectManagerMock->expects($this->never())
69  ->method('create')
70  ->willReturn($configMock);
71 
72  $this->fixtureModelMock
73  ->expects($this->never())
74  ->method('getObjectManager')
75  ->will($this->returnValue($objectManagerMock));
76  $this->fixtureModelMock
77  ->expects($this->once())
78  ->method('getValue')
79  ->willReturn(false);
80 
81  $this->model->execute();
82  }
83 
84  public function testGetActionTitle()
85  {
86  $this->assertSame('Config Changes', $this->model->getActionTitle());
87  }
88 
89  public function testIntroduceParamLabels()
90  {
91  $this->assertSame([], $this->model->introduceParamLabels());
92  }
93 }