public function testGenerateCachePerScopeGlobal() { $definitionCollection = $this->getDefinitionsCollection(); $this->diContainerConfig->expects($this->any())->method('getVirtualTypes')->willReturn($this->getVirtualTypes()); $this->diContainerConfig->expects($this->any())->method('getPreferences')->willReturn($this->getPreferences()); $getResolvedConstructorArgumentsMap = $this->getResolvedVirtualConstructorArgumentsMap($definitionCollection, $this->getVirtualTypes()); $this->diContainerConfig->expects($this->any())->method('getInstanceType')->willReturnMap($this->getInstanceTypeMap($this->getVirtualTypes())); $this->diContainerConfig->expects($this->any())->method('getPreference')->willReturnMap($this->getPreferencesMap()); $isConcreteMap = []; foreach ($definitionCollection->getInstancesNamesList() as $instanceType) { $isConcreteMap[] = [$instanceType, strpos($instanceType, 'Interface') === false]; $getResolvedConstructorArgumentsMap[] = [$instanceType, $definitionCollection->getInstanceArguments($instanceType), $this->getResolvedArguments($definitionCollection->getInstanceArguments($instanceType))]; } $this->typeReader->expects($this->any())->method('isConcrete')->willReturnMap($isConcreteMap); $this->argumentsResolver->expects($this->any())->method('getResolvedConstructorArguments')->willReturnMap($getResolvedConstructorArgumentsMap); $this->assertEquals($this->getExpectedGlobalConfig(), $this->model->generateCachePerScope($definitionCollection, Area::AREA_GLOBAL)); }
/** * {@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); } }