Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Zend\ServiceManager\Di: Fixed issue with proxy object not having the …

…configuration various instance manager settigns
  • Loading branch information...
commit 4b2ed73f61b3ef7335f5a28c642fd1f14a844c56 1 parent 7ef823a
@ralphschindler ralphschindler authored
View
7 library/Zend/ServiceManager/Di/DiInstanceManagerProxy.php
@@ -25,6 +25,13 @@ public function __construct(DiInstanceManager $diInstanceManager, ServiceLocator
{
$this->diInstanceManager = $diInstanceManager;
$this->serviceLocator = $serviceLocator;
+
+ // localize state
+ $this->aliases = &$diInstanceManager->aliases;
+ $this->sharedInstances = &$diInstanceManager->sharedInstances;
+ $this->sharedInstancesWithParams = &$diInstanceManager->sharedInstancesWithParams;
+ $this->configurations = &$diInstanceManager->configurations;
+ $this->typePreferences = &$diInstanceManager->typePreferences;
}
/**
View
16 tests/Zend/ServiceManager/Di/DiServiceInitializerTest.php
@@ -18,6 +18,7 @@ class DiServiceInitializerTest extends \PHPUnit_Framework_TestCase
protected $mockDi = null;
protected $mockServiceLocator = null;
protected $mockDiInstanceManagerProxy = null;
+ protected $mockDiInstanceManager = null;
/**@#-*/
public function setup()
@@ -25,7 +26,7 @@ public function setup()
$this->mockDi = $this->getMock('Zend\Di\Di', array('injectDependencies'));
$this->mockServiceLocator = $this->getMock('Zend\ServiceManager\ServiceLocatorInterface');
$this->mockDiInstanceManagerProxy = new DiInstanceManagerProxy(
- $this->getMock('Zend\Di\InstanceManager'),
+ $this->mockDiInstanceManager = $this->getMock('Zend\Di\InstanceManager'),
$this->mockServiceLocator
);
$this->diServiceInitializer = new DiServiceInitializer(
@@ -49,4 +50,17 @@ public function testInitialize()
$this->diServiceInitializer->initialize($instance);
}
+ /**
+ * @covers Zend\ServiceManager\Di\DiServiceInitializer::initialize
+ * @todo this needs to be moved into its own class
+ */
+ public function testProxyInstanceManagersStayInSync()
+ {
+ $instanceManager = new \Zend\Di\InstanceManager();
+ $proxy = new DiInstanceManagerProxy($instanceManager, $this->mockServiceLocator);
+ $instanceManager->addAlias('foo', 'bar');
+
+ $this->assertEquals($instanceManager->getAliases(), $proxy->getAliases());
+ }
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.