@@ -276,11 +276,9 @@ console::
276276 {
277277 public function testExecute()
278278 {
279- $kernel = self::bootKernel ();
279+ $kernel = static::createKernel ();
280280 $application = new Application($kernel);
281281
282- $application->add(new CreateUserCommand());
283-
284282 $command = $application->find('app:create-user');
285283 $commandTester = new CommandTester($command);
286284 $commandTester->execute(array(
@@ -312,39 +310,6 @@ console::
312310 :class: `Symfony\\ Component\\ Console\\ Application <Symfony\\ Component\\ Console\\ Application> `
313311 and extend the normal ``\PHPUnit\Framework\TestCase ``.
314312
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-
348313Learn More
349314----------
350315
0 commit comments