@@ -276,11 +276,9 @@ console::
276
276
{
277
277
public function testExecute()
278
278
{
279
- $kernel = self::bootKernel ();
279
+ $kernel = static::createKernel ();
280
280
$application = new Application($kernel);
281
281
282
- $application->add(new CreateUserCommand());
283
-
284
282
$command = $application->find('app:create-user');
285
283
$commandTester = new CommandTester($command);
286
284
$commandTester->execute(array(
@@ -312,39 +310,6 @@ console::
312
310
:class: `Symfony\\ Component\\ Console\\ Application <Symfony\\ Component\\ Console\\ Application> `
313
311
and extend the normal ``\PHPUnit\Framework\TestCase ``.
314
312
315
- To be able to use the fully set up service container for your console tests
316
- you can extend your test from
317
- :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ KernelTestCase `::
318
-
319
- // ...
320
- use Symfony\Component\Console\Tester\CommandTester;
321
- use Symfony\Bundle\FrameworkBundle\Console\Application;
322
- use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
323
-
324
- class CreateUserCommandTest extends KernelTestCase
325
- {
326
- public function testExecute()
327
- {
328
- $kernel = static::createKernel();
329
- $kernel->boot();
330
-
331
- $application = new Application($kernel);
332
- $application->add(new CreateUserCommand());
333
-
334
- $command = $application->find('app:create-user');
335
- $commandTester = new CommandTester($command);
336
- $commandTester->execute(array(
337
- 'command' => $command->getName(),
338
- 'username' => 'Wouter',
339
- ));
340
-
341
- $output = $commandTester->getDisplay();
342
- $this->assertContains('Username: Wouter', $output);
343
-
344
- // ...
345
- }
346
- }
347
-
348
313
Learn More
349
314
----------
350
315
0 commit comments