I was wondering how I could retrieve the entitymanager inside of a WebTestCase instance.
e.g. to look whether a entity was really created in DB during the testrun.
Any ideas on that ?
You can retrieve the DIC (Dependency Injection Container) through the Kernel, which is a protected member of the WebTestCase.
You could do this from within your WebTestCase:
$em = $this->kernel->getContainer()->get('doctrine.orm.entity_manager');
Update
From your own comment, there is even a shortcut for this (since you will have a client anyway):
$client = $this->getClient(); $container = $client->getContainer();
As is mentioned in the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With