diff --git a/Registry.php b/Registry.php index 4f28cace2..ae9e74739 100644 --- a/Registry.php +++ b/Registry.php @@ -168,7 +168,7 @@ public function getEntityManagerForClass($class) public function reset() : void { - foreach ($this->getManagerNames() as $managerName) { + foreach (array_keys($this->getManagerNames()) as $managerName) { $this->resetManager($managerName); } } diff --git a/Tests/RegistryTest.php b/Tests/RegistryTest.php index 9693ab45d..89ebb7dda 100644 --- a/Tests/RegistryTest.php +++ b/Tests/RegistryTest.php @@ -122,4 +122,20 @@ public function testResetUnknownEntityManager() $registry->resetManager('default'); } + + /** + * @group legacy + */ + public function testReset() + { + $em = new stdClass(); + $container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); + $container->expects($this->once()) + ->method('get') + ->with($this->equalTo('doctrine.orm.default_entity_manager')) + ->will($this->returnValue($em)); + + $registry = new Registry($container, [], ['default' => 'doctrine.orm.default_entity_manager'], 'default', 'default'); + $registry->reset(); + } }