$container =
new ContainerBuilder();
$loader =
new XmlFileLoader($container,
new FileLocator(self::
$fixturesPath.'/xml'
));
$loader->
load('services5.xml'
);
$services =
$container->
getDefinitions();
$this->
assertCount(6,
$services, '->load() attributes unique ids to anonymous services'
);
// anonymous service as an argument
$args =
$services['foo'
]->
getArguments();
$this->
assertCount(1,
$args, '->load() references anonymous services as "normal" ones'
);
$this->
assertInstanceOf(Reference::
class,
$args[0
], '->load() converts anonymous services to references to "normal" services'
);
$this->
assertArrayHasKey((string) $args[0
],
$services, '->load() makes a reference to the created ones'
);
$inner =
$services[(string) $args[0
]];
$this->
assertEquals('BarClass',
$inner->
getClass(), '->load() uses the same configuration as for the anonymous ones'
);
$this->
assertFalse($inner->
isPublic());
// inner anonymous services
$args =
$inner->
getArguments();
$this->
assertCount(1,
$args, '->load() references anonymous services as "normal" ones'
);
$this->
assertInstanceOf(Reference::
class,
$args[0
], '->load() converts anonymous services to references to "normal" services'
);
$this->
assertArrayHasKey((string) $args[0
],
$services, '->load() makes a reference to the created ones'
);
$inner =
$services[(string) $args[0
]];
$this->
assertEquals('BazClass',
$inner->
getClass(), '->load() uses the same configuration as for the anonymous ones'
);