Esempio n. 1
0
 public function testAddCollection()
 {
     $this->model->addDefinition(self::INSTANCE_1, $this->getArgument());
     $this->collectionMock->expects($this->any())->method('getCollection')->willReturn([self::INSTANCE_2 => $this->getArgument()]);
     $this->model->addCollection($this->collectionMock);
     $this->assertEquals([self::INSTANCE_1 => $this->getArgument(), self::INSTANCE_2 => $this->getArgument()], $this->model->getCollection());
 }
Esempio n. 2
0
 /**
  * Returns definitions collection
  *
  * @param string $path
  * @return DefinitionsCollection
  */
 protected function getDefinitionsCollection($path)
 {
     $definitions = new DefinitionsCollection();
     foreach ($this->classesScanner->getList($path) as $className => $constructorArguments) {
         $definitions->addDefinition($className, $constructorArguments);
     }
     return $definitions;
 }
Esempio n. 3
0
 public function testDoOperationGlobalArea()
 {
     $path = 'path/to/codebase/';
     $generatedConfig = ['arguments' => [], 'nonShared' => [], 'preferences' => [], 'instanceTypes' => []];
     $definitions = new DefinitionsCollection();
     $definitions->addDefinition('class', []);
     $areaOperation = new Area($this->areaListMock, $this->classesScannerMock, $this->configReaderMock, $this->configWriterMock, [$path]);
     $this->areaListMock->expects($this->once())->method('getCodes')->willReturn([]);
     $this->classesScannerMock->expects($this->once())->method('getList')->with($path)->willReturn(['class' => []]);
     $this->configReaderMock->expects($this->once())->method('generateCachePerScope')->with($this->isInstanceOf('Magento\\Tools\\Di\\Definition\\Collection'), App\Area::AREA_GLOBAL)->willReturn($generatedConfig);
     $this->configWriterMock->expects($this->once())->method('write')->with(App\Area::AREA_GLOBAL, $generatedConfig);
     $areaOperation->doOperation();
 }
Esempio n. 4
0
 /**
  * Returns preferences for third party code
  *
  * @param ConfigInterface $config
  * @param DefinitionsCollection $definitionsCollection
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  *
  * @return void
  */
 private function fillThirdPartyInterfaces(ConfigInterface $config, DefinitionsCollection $definitionsCollection)
 {
     $definedInstances = $definitionsCollection->getInstancesNamesList();
     foreach ($config->getPreferences() as $interface => $preference) {
         if (in_array($interface, $definedInstances)) {
             continue;
         }
         $definitionsCollection->addDefinition($interface, []);
     }
 }
Esempio n. 5
0
 /**
  * @param Collection $definitionCollection
  * @param array $virtualTypes
  * @return array
  */
 private function getResolvedVirtualConstructorArgumentsMap(Collection $definitionCollection, array $virtualTypes)
 {
     $getResolvedConstructorArgumentsMap = [];
     foreach ($virtualTypes as $virtualType => $concreteType) {
         $getResolvedConstructorArgumentsMap[] = [$virtualType, $definitionCollection->getInstanceArguments($concreteType), $this->getResolvedArguments($definitionCollection->getInstanceArguments($concreteType))];
     }
     return $getResolvedConstructorArgumentsMap;
 }