Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPUnit test case aware of symfony2 dependency injection container

I'm actually testing a bundle that I created. All the code is fully unit tested but now, I want to test if my symfony2 services can be request without any trouble.

For that, I need the symfony2 dependency injection container in my test case. How can I do that ?

like image 383
egeloen Avatar asked Sep 29 '11 15:09

egeloen


1 Answers

I recently asked a question similar to this in that I needed just the validator, however the person who replied to my question first had a solution which gave access to the whole container.

Basically you can pick apart WebTestCase in order to see how it builds the Symfony2 environment and make your own base class which is Symfony aware as it were.

Here is the answer, I hope it helps: Symfony2: Testing entity validation constraints

like image 122
Kasheen Avatar answered Oct 16 '22 23:10

Kasheen