Skip to content
This repository was archived by the owner on Jan 21, 2020. It is now read-only.

Commit ee8ba14

Browse files
committed
Added more delegator tests
1 parent 9c3bccf commit ee8ba14

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/DelegatorTestTrait.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,31 @@ public function testDelegatorsNamedForAliasDoNotApplyToInvokableServiceResolvedV
119119
self::assertSame($instance, $container->get(TestAsset\Service::class));
120120
}
121121

122+
public function testDelegatorsNamedForAliasDoNotApplyToInvokableServiceWithAlias() : void
123+
{
124+
$config = [
125+
'invokables' => [
126+
'alias' => TestAsset\Service::class,
127+
],
128+
'delegators' => [
129+
'alias' => [
130+
TestAsset\DelegatorFactory::class,
131+
],
132+
],
133+
];
134+
135+
$container = $this->createContainer($config);
136+
137+
self::assertTrue($container->has('alias'));
138+
$instance = $container->get('alias');
139+
self::assertInstanceOf(TestAsset\Service::class, $instance);
140+
self::assertNotInstanceOf(TestAsset\Delegator::class, $instance);
141+
142+
// Now ensure that the instance already retrieved by alias is the same
143+
// as that when fetched by the canonical service name.
144+
self::assertSame($instance, $container->get(TestAsset\Service::class));
145+
}
146+
122147
public function testDelegatorsDoNotApplyToAliasResolvingToServiceEntry() : void
123148
{
124149
$myService = new TestAsset\Service();

0 commit comments

Comments
 (0)