开发者

PHPUnit test case aware of symfony2 dependency injection container

开发者 https://www.devze.com 2023-04-09 15:08 出处:网络
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.

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 ?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号