Fix referencing context initializers

With definition, that has been used instead of reference, container has
used to created 2 instances of initializer: one with service id, and one
"anonymous", described by spl_object_hash in a container, it breaked
stateful initializers: in my case initializer was also used to reset
state before next scenario/example, and initializing and resetting happened
with different instances of initializer
This commit is contained in:
Alexander Kurilo
2019-12-08 23:30:09 +03:00
committed by Kamil Kokot
parent 8af487dd5a
commit 06104478cc
2 changed files with 90 additions and 1 deletions

View File

@@ -182,7 +182,7 @@ final class SymfonyExtension implements Extension
{
$definition = $container->findDefinition('fob_symfony.environment_handler.context_service');
foreach ($container->findTaggedServiceIds(ContextExtension::INITIALIZER_TAG) as $serviceId => $tags) {
$definition->addMethodCall('registerContextInitializer', [$container->getDefinition($serviceId)]);
$definition->addMethodCall('registerContextInitializer', [new Reference($serviceId)]);
}
}