From 32e1e852378201c6ebe39b500497dd8a3191d909 Mon Sep 17 00:00:00 2001 From: Dennis Riehle Date: Sun, 17 Jan 2021 16:09:24 +0100 Subject: [PATCH] backported testConfigureInvokablesTakePrecedenceOverFactories to 3.5.x Signed-off-by: Dennis Riehle --- test/CommonServiceLocatorBehaviorsTrait.php | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/CommonServiceLocatorBehaviorsTrait.php b/test/CommonServiceLocatorBehaviorsTrait.php index 646d9706..167ecf4b 100644 --- a/test/CommonServiceLocatorBehaviorsTrait.php +++ b/test/CommonServiceLocatorBehaviorsTrait.php @@ -327,6 +327,29 @@ public function testConfigureCanOverridePreviousSettings() $newServiceManager->get(DateTime::class); } + public function testConfigureInvokablesTakePrecedenceOverFactories() + { + $firstFactory = $this->getMockBuilder(FactoryInterface::class) + ->getMock(); + + $serviceManager = $this->createContainer([ + 'aliases' => [ + 'custom_alias' => DateTime::class, + ], + 'factories' => [ + DateTime::class => $firstFactory, + ], + 'invokables' => [ + 'custom_alias' => stdClass::class, + ], + ]); + + $firstFactory->expects($this->never())->method('__invoke'); + + $object = $serviceManager->get('custom_alias'); + $this->assertInstanceOf(stdClass::class, $object); + } + /** * @group has */