+ public function testRunDispatchesIntegerExitCode()
+ {
+ $passedRightValue = false;
+
+ // We can assume here that some other test asserts that the event is dispatched at all
+ $dispatcher = new EventDispatcher();
+ $dispatcher->addListener('console.terminate', function (ConsoleTerminateEvent $event) use (&$passedRightValue) {
+ $passedRightValue = (4 === $event->getExitCode());
+ });
+
+ $application = new Application();
+ $application->setDispatcher($dispatcher);
+ $application->setAutoExit(false);
+
+ $application->register('test')->setCode(function (InputInterface $input, OutputInterface $output) {
+ throw new \Exception('', 4);
+ });
+
+ $tester = new ApplicationTester($application);
+ $tester->run(array('command' => 'test'));
+
+ $this->assertTrue($passedRightValue, '-> exit code 4 was passed in the console.terminate event');
+ }
+