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 registerRawService($rawServiceSpecs)
 {
     $specs = AbstractServiceSpecs::factory($rawServiceSpecs);
     $this->registerService($specs);
     return $this;
 }
 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']);
 }
 public function testAbstractServiceSpecsReturnsAnUndefinedServiceSpecsIfNoActualSpecsIsMatchesServiceDefinition()
 {
     $serviceSpec = AbstractServiceSpecs::factory(['id' => 'test.service']);
     $this->assertInstanceOf(UndefinedServiceSpecs::class, $serviceSpec);
 }