How to test a shared Symfony 2 Bundle without a full project How to test a shared Symfony 2 Bundle without a full project symfony symfony

How to test a shared Symfony 2 Bundle without a full project


This question is quite old, but I just stumbled upon it.

Bundles are a Symfony specific way to share entire libraries incl. their respective dependency injection container configuration.

Therefore, bundles depend on the Symfony kernel and if one bundle depends on another bundle, you create heavy dependencies, which effectively prevents unit testing: To test a unit (a class) in bundle A, you'll need bundle B plus the Symfony kernel.

You can still test, but the resulting tests are acceptance / integration tests, not unit tests anymore. Those are not suitable for test driven development, slow and fragile, as you already noticed.

Update

I just wrote a blog post about this:https://lastzero.net/2015/11/dependent-symfony-2-bundles-and-testability/