public function testFactoryCanGuessTypeForDefaultSpecs()
 {
     // class
     $rawSpecs = ['id' => 'service.id', 'class' => 'Service\\Class'];
     $serviceSpecs = AbstractServiceSpecs::factory($rawSpecs);
     $this->assertInstanceOf(ClassServiceSpecs::class, $serviceSpecs);
     // prefab
     $rawSpecs = ['id' => 'service.id', 'instance' => new \stdClass()];
     $serviceSpecs = AbstractServiceSpecs::factory($rawSpecs);
     $this->assertInstanceOf(PrefabServiceSpecs::class, $serviceSpecs);
     // ambiguous
     $rawSpecs = ['id' => 'service.id', 'class' => 'Service\\Class', 'instance' => new \stdClass()];
     $this->expectsException(function () use($rawSpecs) {
         $serviceSpecs = AbstractServiceSpecs::factory($rawSpecs);
     }, Exception::class, '', Exception::AMBIGUOUS_SERVICE_SPECS);
     // incomplete
     $rawSpecs = [];
     $this->expectsException(function () use($rawSpecs) {
         $serviceSpecs = AbstractServiceSpecs::factory($rawSpecs);
     }, Exception::class, '', Exception::INCOMPLETE_SERVICE_SPECS);
 }
 public function testFactoryCanRegisterServicesFromRawSpecifications()
 {
     // class
     $rawSpecs = ['id' => 'service.id', 'class' => 'Service\\Class'];
     $factory = new ServicesFactory();
     $factory->registerRawService($rawSpecs);
     $this->assertEquals(AbstractServiceSpecs::factory($rawSpecs), $factory->getServices()['service.id']);
 }
 /**
  * @param       $id
  * @param array $params
  *
  */
 public function __construct($id, $params = [])
 {
     parent::__construct($id);
     $this->setParams($params);
 }
 public function registerRawService($rawServiceSpecs)
 {
     $specs = AbstractServiceSpecs::factory($rawServiceSpecs);
     $this->registerService($specs);
     return $this;
 }
 public function testAbstractServiceSpecsReturnsAnUndefinedServiceSpecsIfNoActualSpecsIsMatchesServiceDefinition()
 {
     $serviceSpec = AbstractServiceSpecs::factory(['id' => 'test.service']);
     $this->assertInstanceOf(UndefinedServiceSpecs::class, $serviceSpec);
 }
 /**
  * @param $id
  * @param $instance
  */
 public function __construct($id, $instance)
 {
     parent::__construct($id);
     $this->setInstance($instance);
 }
 /**
  * @param $id
  * @param $class
  */
 public function __construct($id, $class)
 {
     parent::__construct($id);
     $this->setters = new Collection();
     $this->setClass($class);
 }