Esempio n. 1
0
 /**
  * @covers Zend\ServiceManager\ServiceManager::setAlias
  * @covers Zend\ServiceManager\ServiceManager::get
  * @covers Zend\ServiceManager\ServiceManager::retrieveFromPeeringManager
  */
 public function testCanGetAliasedServicesFromPeeringServiceManagers()
 {
     $service = new \stdClass();
     $peeringSm = new ServiceManager();
     $peeringSm->setService('actual-service-name', $service);
     $this->serviceManager->addPeeringServiceManager($peeringSm);
     $this->serviceManager->setAlias('alias-name', 'actual-service-name');
     $this->assertSame($service, $this->serviceManager->get('alias-name'));
 }
 /**
  * @covers Zend\ServiceManager\ServiceManager::setService
  * @covers Zend\ServiceManager\ServiceManager::get
  * @covers Zend\ServiceManager\ServiceManager::retrieveFromPeeringManagerFirst
  * @covers Zend\ServiceManager\ServiceManager::setRetrieveFromPeeringManagerFirst
  * @covers Zend\ServiceManager\ServiceManager::addPeeringServiceManager
  */
 public function testRetrieveServiceFromPeeringServiceManagerIfretrieveFromPeeringManagerFirstSetToTrueAndServiceNamesAreSame()
 {
     $foo1 = "foo1";
     $boo1 = "boo1";
     $boo2 = "boo2";
     $this->serviceManager->setService($foo1, $boo1);
     $this->assertEquals($this->serviceManager->get($foo1), $boo1);
     $serviceManagerChild = new ServiceManager();
     $serviceManagerChild->setService($foo1, $boo2);
     $this->assertEquals($serviceManagerChild->get($foo1), $boo2);
     $this->assertFalse($this->serviceManager->retrieveFromPeeringManagerFirst());
     $this->serviceManager->setRetrieveFromPeeringManagerFirst(true);
     $this->assertTrue($this->serviceManager->retrieveFromPeeringManagerFirst());
     $this->serviceManager->addPeeringServiceManager($serviceManagerChild);
     $this->assertContains($serviceManagerChild, $this->readAttribute($this->serviceManager, 'peeringServiceManagers'));
     $this->assertEquals($serviceManagerChild->get($foo1), $boo2);
     $this->assertEquals($this->serviceManager->get($foo1), $boo2);
 }
Esempio n. 3
0
 public function testAllowsRetrievingFromPeeringContainerFirst()
 {
     $parent = new ServiceManager();
     $parent->setFactory('foo', function ($sm) {
         return 'bar';
     });
     $child = new ServiceManager();
     $child->setFactory('foo', function ($sm) {
         return 'baz';
     });
     $child->addPeeringServiceManager($parent, ServiceManager::SCOPE_PARENT);
     $child->setRetrieveFromPeeringManagerFirst(true);
     $this->assertEquals('bar', $child->get('foo'));
 }