public function testModify() { $inputArray = ['data' => [1, 2, 3]]; $expectedArray1 = ['data' => [1, 2, 3, 1]]; $expectedArray2 = ['data' => [1, 2, 3, 1, 1]]; $modifier1 = $this->getMockBuilder('Magento\\Setup\\Module\\Di\\Compiler\\Config\\ModificationInterface')->getMock(); $modifier2 = $this->getMockBuilder('Magento\\Setup\\Module\\Di\\Compiler\\Config\\ModificationInterface')->getMock(); $modificationsList = [$modifier1, $modifier2]; $modifier1->expects($this->once())->method('modify')->with($inputArray)->willReturn($expectedArray1); $modifier2->expects($this->once())->method('modify')->with($expectedArray1)->willReturn($expectedArray2); $chain = new ModificationChain($modificationsList); $this->assertEquals($expectedArray2, $chain->modify($inputArray)); }
/** * {@inheritdoc} */ public function doOperation() { if (empty($this->data)) { return; } $definitionsCollection = new DefinitionsCollection(); foreach ($this->data as $paths) { if (!is_array($paths)) { $paths = (array) $paths; } foreach ($paths as $path) { $definitionsCollection->addCollection($this->getDefinitionsCollection($path)); } } $areaCodes = array_merge([App\Area::AREA_GLOBAL], $this->areaList->getCodes()); foreach ($areaCodes as $areaCode) { $config = $this->configReader->generateCachePerScope($definitionsCollection, $areaCode); $config = $this->modificationChain->modify($config); $this->configWriter->write($areaCode, $config); } }