@@ -216,21 +216,16 @@ console::
216216 namespace Tests\AppBundle\Command;
217217
218218 use AppBundle\Command\CreateUserCommand;
219- use Symfony\Component\Console\Application;
220- // use this if you're in the Symfony Framework
221- //use Symfony\Bundle\FrameworkBundle\Console\Application;
219+ use Symfony\Bundle\FrameworkBundle\Console\Application;
220+ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
222221 use Symfony\Component\Console\Tester\CommandTester;
223222
224- class CreateUserCommandTest extends \PHPUnit_Framework_TestCase
223+ class CreateUserCommandTest extends KernelTestCase
225224 {
226225 public function testExecute()
227226 {
228- $application = new Application();
229-
230- // if you're in the Symfony framework, do this instead
231- // extend the KernelTestCase class
232- // self::bootKernel();
233- // $application = new Application(self::$kernel);
227+ self::bootKernel();
228+ $application = new Application(self::$kernel);
234229
235230 $application->add(new CreateUserCommand());
236231
@@ -259,6 +254,12 @@ console::
259254 You can also test a whole console application by using
260255 :class: `Symfony\\ Component\\ Console\\ Tester\\ ApplicationTester `.
261256
257+ .. note ::
258+
259+ When using the Console component in a standalone project, use
260+ :class: `Symfony\\ Component\\ Console\\ Application <Symfony\\ Component\\ Console\\ Application> `
261+ and extend the normal ``\PHPUnit_Framework_TestCase ``.
262+
262263To be able to use the fully set up service container for your console tests
263264you can extend your test from
264265:class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ KernelTestCase `::
0 commit comments