I have not tried this solution, but I am sure that this is a good advantage.
My unit test class extends Symfony\Bundle\FrameworkBundle\Test\WebTestCase , which allows you to create a Client that Kernel creates itself.
In unit test you can do this:
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class DatabaseRelatedTest extends WebTestCase { private static $client; public function setUp() {
You will be able to access EntityManager and by expanding Connection using the client container.
self::$client->getContainer()->get('doctrine')
It would be ideal to pass the environment name to the setUp method using the phpunit.xml.dist file. This is probably a semi-answer, but I think this is a good result.
source share