Using phpspec for testing Symfony2 Commands Using phpspec for testing Symfony2 Commands symfony symfony

Using phpspec for testing Symfony2 Commands


You can use PhpSpec to test Command in a unit testable way - it's not too bad but you end up with a lot of mocking of input/output.

It's better to keep your Commands nice and small, with them delegating to other services that are unit tested - then you can cover with Behat and get your confidence that they're working.

It's a very similar problem to testing Controllers, just that Commands have more dependencies to mock if you try the unit testing approach.


You should use Behat for this, not phpspec