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()); }
/** * @return Collection */ private function getDefinitionsCollection() { $definitionCollection = new Collection(); $definitionCollection->addDefinition('ConcreteType1', ['argument1', 'argument2']); $definitionCollection->addDefinition('ConcreteType2', ['argument1', 'argument2']); $definitionCollection->addDefinition('Interface1', [null]); return $definitionCollection; }
/** * Returns definitions collection * * @param string $path * @return DefinitionsCollection */ protected function getDefinitionsCollection($path) { $definitions = new DefinitionsCollection(); foreach ($this->areaInstancesNamesList->getList($path) as $className => $constructorArguments) { $definitions->addDefinition($className, $constructorArguments); } return $definitions; }
/** * Returns preferences for third party code * * @param ConfigInterface $config * @param DefinitionsCollection $definitionsCollection * * @return void */ private function fillThirdPartyInterfaces(ConfigInterface $config, DefinitionsCollection $definitionsCollection) { $definedInstances = $definitionsCollection->getInstancesNamesList(); foreach (array_keys($config->getPreferences()) as $interface) { if (in_array($interface, $definedInstances)) { continue; } $definitionsCollection->addDefinition($interface, []); } }