You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just got the same issue. Injecting a Symfony service into a Behat context via a constructor argument is different than retrieving it from the kernel injected via KernelAwareContext::setKernel().
I think this is because the container itself it reset on kernel boot so the test container (test.service_container) is reset as well. This means that retrieving private services from it might return new instances instead of the ones previously retrieved (e.g. when injecting them via contexts' constructor).
@julienfalque it seems I got stuck into the same issue. I have a context with dependency on symfony service. Controller of dependency class called 2 times.
Did you manage to create any workaround?
Hi,
I just discover a small difference between access
getContainer
from theKernelDictionary::getContainer()
.If I understand correctly, the kernel is rebooted after each scenario or if we call an http request from symfony framework client.
This mean that all services are reinitialized, and particularly doctrine entity managers.
But's that is not really the recommended way of doing this in Symfony 3+ (private services, autowiring, etc.).
On the other hand, if we do inject doctrine as a parameter in
behat.yml
like this :Then the instance of entity manager is not reinitialized when the kernel is rebooted (and thus the unit of work is not "cleared").
I made a "patch" with a context that clear every unit of work after each step, but it's a bit weird, and other users may have similar bugs.
Thanks
The text was updated successfully, but these errors were encountered: