@@ -216,21 +216,16 @@ console::
216
216
namespace Tests\AppBundle\Command;
217
217
218
218
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;
222
221
use Symfony\Component\Console\Tester\CommandTester;
223
222
224
- class CreateUserCommandTest extends \PHPUnit_Framework_TestCase
223
+ class CreateUserCommandTest extends KernelTestCase
225
224
{
226
225
public function testExecute()
227
226
{
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);
234
229
235
230
$application->add(new CreateUserCommand());
236
231
@@ -259,6 +254,12 @@ console::
259
254
You can also test a whole console application by using
260
255
:class: `Symfony\\ Component\\ Console\\ Tester\\ ApplicationTester `.
261
256
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
+
262
263
To be able to use the fully set up service container for your console tests
263
264
you can extend your test from
264
265
:class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ KernelTestCase `::
0 commit comments