You should use the `CommandTester` class.

http://symfony.com/doc/current/components/console/introduction.html#testing-commands