Skip to content

Commit 11c6b38

Browse files
committed
Ensure services & aliases can be referred to with __toStringable objects
1 parent 483dd13 commit 11c6b38

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,24 @@ public function testArgumentsHaveHigherPriorityThanBindings()
13101310
$this->assertSame('via-argument', $container->get('foo')->class1->identifier);
13111311
$this->assertSame('via-bindings', $container->get('foo')->class2->identifier);
13121312
}
1313+
1314+
public function testIdCanBeAnObjectAsLongAsItCanBeCastToString()
1315+
{
1316+
$id = new Reference('another_service');
1317+
$aliasId = new Reference('alias_id');
1318+
1319+
$container = new ContainerBuilder();
1320+
$container->set($id, new \stdClass());
1321+
$container->setAlias($aliasId, 'another_service');
1322+
1323+
$this->assertTrue($container->has('another_service'));
1324+
$this->assertTrue($container->has($id));
1325+
$this->assertTrue($container->hasAlias('alias_id'));
1326+
$this->assertTrue($container->hasAlias($aliasId));
1327+
1328+
$container->removeAlias($aliasId);
1329+
$container->removeDefinition($id);
1330+
}
13131331
}
13141332

13151333
class FooClass

0 commit comments

Comments
 (0)