You are here

protected function ApplicationTest::getDispatcher in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Tests/ApplicationTest.php \Symfony\Component\Console\Tests\ApplicationTest::getDispatcher()
4 calls to ApplicationTest::getDispatcher()
ApplicationTest::testRunDispatchesAllEventsWithException in vendor/symfony/console/Tests/ApplicationTest.php
ApplicationTest::testRunWithDispatcher in vendor/symfony/console/Tests/ApplicationTest.php
ApplicationTest::testRunWithDispatcherSkippingCommand in vendor/symfony/console/Tests/ApplicationTest.php
ApplicationTest::testRunWithExceptionAndDispatcher in vendor/symfony/console/Tests/ApplicationTest.php
@expectedException \LogicException @expectedExceptionMessage caught

File

vendor/symfony/console/Tests/ApplicationTest.php, line 957

Class

ApplicationTest

Namespace

Symfony\Component\Console\Tests

Code

protected function getDispatcher($skipCommand = false) {
  $dispatcher = new EventDispatcher();
  $dispatcher
    ->addListener('console.command', function (ConsoleCommandEvent $event) use ($skipCommand) {
    $event
      ->getOutput()
      ->write('before.');
    if ($skipCommand) {
      $event
        ->disableCommand();
    }
  });
  $dispatcher
    ->addListener('console.terminate', function (ConsoleTerminateEvent $event) use ($skipCommand) {
    $event
      ->getOutput()
      ->writeln('after.');
    if (!$skipCommand) {
      $event
        ->setExitCode(113);
    }
  });
  $dispatcher
    ->addListener('console.exception', function (ConsoleExceptionEvent $event) {
    $event
      ->getOutput()
      ->write('caught.');
    $event
      ->setException(new \LogicException('caught.', $event
      ->getExitCode(), $event
      ->getException()));
  });
  return $dispatcher;
}