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

Commit b9bbd4f

Browse files
malininkOcramius
authored andcommitted
add test to setAlias method
1 parent 2aec46d commit b9bbd4f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/ServiceManagerTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,4 +236,29 @@ public function testAliasToAnExplicitServiceShouldWork()
236236

237237
$this->assertSame($service, $alias);
238238
}
239+
240+
/**
241+
* @depends testAliasToAnExplicitServiceShouldWork
242+
*/
243+
public function testSetAliasShouldWorkWithRecursiveAlias()
244+
{
245+
$config = [
246+
'aliases' => [
247+
'Alias' => 'TailInvokable',
248+
],
249+
'services' => [
250+
InvokableObject::class => new InvokableObject(),
251+
],
252+
];
253+
$serviceManager = new ServiceManager($config);
254+
$serviceManager->setAlias('HeadAlias', 'Alias');
255+
$serviceManager->setAlias('TailInvokable', InvokableObject::class);
256+
257+
$service = $serviceManager->get(InvokableObject::class);
258+
$alias = $serviceManager->get('Alias');
259+
$headAlias = $serviceManager->get('HeadAlias');
260+
261+
$this->assertSame($service, $alias);
262+
$this->assertSame($service, $headAlias);
263+
}
239264
}

0 commit comments

Comments
 (0)