configImporterPoolMock = $this->getMockBuilder(ImporterPool::class) ->disableOriginalConstructor() ->getMock(); $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class) ->disableOriginalConstructor() ->getMock(); $this->dataCollector = new DataCollector($this->configImporterPoolMock, $this->deploymentConfigMock); } /** * @return void */ public function testGetConfig() { $sections = ['first', 'second']; $this->configImporterPoolMock->expects($this->once()) ->method('getSections') ->willReturn($sections); $this->deploymentConfigMock->expects($this->atLeastOnce()) ->method('getConfigData') ->willReturnMap([['first', 'some data']]); $this->assertSame(['first' => 'some data', 'second' => null], $this->dataCollector->getConfig()); } /** * @return void */ public function testGetConfigSpecificSection() { $this->configImporterPoolMock->expects($this->never()) ->method('getSections'); $this->deploymentConfigMock->expects($this->atLeastOnce()) ->method('getConfigData') ->willReturnMap([['someSection', 'some data']]); $this->assertSame(['someSection' => 'some data'], $this->dataCollector->getConfig('someSection')); } }