public function testServicesNotShared() { $this->serviceLocator->add('DesignPatterns\\More\\ServiceLocator\\LogServiceInterface', $this->logService, false); $this->serviceLocator->add('DesignPatterns\\More\\ServiceLocator\\DatabaseServiceInterface', $this->databaseService, false); $this->assertNotSame($this->logService, $this->serviceLocator->get('DesignPatterns\\More\\ServiceLocator\\LogServiceInterface')); $this->assertInstanceOf('DesignPatterns\\More\\ServiceLocator\\LogServiceInterface', $this->serviceLocator->get('DesignPatterns\\More\\ServiceLocator\\LogServiceInterface')); $this->assertNotSame($this->databaseService, $this->serviceLocator->get('DesignPatterns\\More\\ServiceLocator\\DatabaseServiceInterface')); $this->assertInstanceOf('DesignPatterns\\More\\ServiceLocator\\DatabaseServiceInterface', $this->serviceLocator->get('DesignPatterns\\More\\ServiceLocator\\DatabaseServiceInterface')); }
public function testGetWillInstantiateLogServiceIfNoInstanceHasBeenCreatedYet() { $this->serviceLocator->addClass(LogService::class, []); $logger = $this->serviceLocator->get(LogService::class); $this->assertInstanceOf('DesignPatterns\\More\\ServiceLocator\\LogService', $logger); }