Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataCollectorTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class DataCollectorTest extends \PHPUnit\Framework\TestCase
13 {
17  private $configImporterPoolMock;
18 
22  private $deploymentConfigMock;
23 
27  private $dataCollector;
28 
32  protected function setUp()
33  {
34  $this->configImporterPoolMock = $this->getMockBuilder(ImporterPool::class)
35  ->disableOriginalConstructor()
36  ->getMock();
37  $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
38  ->disableOriginalConstructor()
39  ->getMock();
40 
41  $this->dataCollector = new DataCollector($this->configImporterPoolMock, $this->deploymentConfigMock);
42  }
43 
47  public function testGetConfig()
48  {
49  $sections = ['first', 'second'];
50  $this->configImporterPoolMock->expects($this->once())
51  ->method('getSections')
52  ->willReturn($sections);
53  $this->deploymentConfigMock->expects($this->atLeastOnce())
54  ->method('getConfigData')
55  ->willReturnMap([['first', 'some data']]);
56 
57  $this->assertSame(['first' => 'some data', 'second' => null], $this->dataCollector->getConfig());
58  }
59 
63  public function testGetConfigSpecificSection()
64  {
65  $this->configImporterPoolMock->expects($this->never())
66  ->method('getSections');
67  $this->deploymentConfigMock->expects($this->atLeastOnce())
68  ->method('getConfigData')
69  ->willReturnMap([['someSection', 'some data']]);
70  $this->assertSame(['someSection' => 'some data'], $this->dataCollector->getConfig('someSection'));
71  }
72 }