From 4284161d9c3683dd893116a9ec9581167ee75bf5 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Mon, 18 Jul 2016 19:07:57 +0100 Subject: [PATCH 01/15] Add basic support for automatic console exception logging --- .../FrameworkExtension.php | 1 + .../Resources/config/console.xml | 13 +++ .../EventListener/ExceptionListener.php | 91 +++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml create mode 100644 src/Symfony/Component/Console/EventListener/ExceptionListener.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 806a06197cafc..9fd21a6d558a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -66,6 +66,7 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('web.xml'); $loader->load('services.xml'); $loader->load('fragment_renderer.xml'); + $loader->load('console.xml'); // A translator must always be registered (as support is included by // default in the Form component). If disabled, an identity translator diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml new file mode 100644 index 0000000000000..62d408977c3b9 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php new file mode 100644 index 0000000000000..4264f8fab937e --- /dev/null +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -0,0 +1,91 @@ + + */ +class ExceptionListener implements EventSubscriberInterface +{ + protected $logger; + + /** + * Constructor. + * + * @param LoggerInterface $logger A logger + */ + public function __construct(LoggerInterface $logger = null) + { + $this->logger = $logger; + } + + /** + * Handles console command exception. + * + * @param ConsoleExceptionEvent $event Console event + */ + public function onKernelException(ConsoleExceptionEvent $event) + { + if (null === $this->logger) { + return; + } + + $exception = $event->getException(); + + $message = sprintf( + '%s: %s (uncaught exception) at %s line %s while running console command `%s`', + get_class($exception), + $exception->getMessage(), + $exception->getFile(), + $exception->getLine(), + $event->getCommand()->getName() + ); + + $this->logger->error($message, array('exception' => $exception)); + } + + /** + * Handles termination of console command. + * + * @param ConsoleTerminateEvent $event Console event + */ + public function onKernelTerminate(ConsoleTerminateEvent $event) + { + if (null === $this->logger) { + return; + } + + $exitCode = $event->getExitCode(); + + if ($exitCode === 0) { + return; + } + + if ($exitCode > 255) { + $event->setExitCode(255); + } + + $message = sprintf('Command `%s` exited with status code %d'); + + $this->logger->warning($message); + } + + public static function getSubscribedEvents() + { + return array( + ConsoleEvents::EXCEPTION => array('onKernelException', -128), + ConsoleEvents::TERMINATE => array('onKernelTerminate', -128) + ); + } +} From 17ef8dbdc55f96e01e9deec63a3f6d6ac6f9801e Mon Sep 17 00:00:00 2001 From: James Halsall Date: Mon, 18 Jul 2016 19:19:47 +0100 Subject: [PATCH 02/15] Fix coding standards --- .../Component/Console/EventListener/ExceptionListener.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 4264f8fab937e..d6a704ed4a535 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -13,7 +13,6 @@ * * Attempts to log exceptions or abnormal terminations of console commands. * - * @package Symfony\Component\Console\EventListener; * @author James Halsall */ class ExceptionListener implements EventSubscriberInterface @@ -85,7 +84,7 @@ public static function getSubscribedEvents() { return array( ConsoleEvents::EXCEPTION => array('onKernelException', -128), - ConsoleEvents::TERMINATE => array('onKernelTerminate', -128) + ConsoleEvents::TERMINATE => array('onKernelTerminate', -128), ); } } From 3d6b22b0696db0ace91cdea281042a102a363867 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Thu, 21 Jul 2016 18:50:24 +0100 Subject: [PATCH 03/15] Simplify the log entry for console exceptions --- .../Console/EventListener/ExceptionListener.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index d6a704ed4a535..d17990027e44e 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -42,16 +42,7 @@ public function onKernelException(ConsoleExceptionEvent $event) $exception = $event->getException(); - $message = sprintf( - '%s: %s (uncaught exception) at %s line %s while running console command `%s`', - get_class($exception), - $exception->getMessage(), - $exception->getFile(), - $exception->getLine(), - $event->getCommand()->getName() - ); - - $this->logger->error($message, array('exception' => $exception)); + $this->logger->error($exception->getMessage(), array('exception' => $exception)); } /** From 0961f8cfc881364170a02b2ec354c89bea458736 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Tue, 9 Aug 2016 19:36:16 +0100 Subject: [PATCH 04/15] Remove unnecessary exit code handling in ExceptionListener --- .../Component/Console/EventListener/ExceptionListener.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index d17990027e44e..98878a7f57c20 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -13,7 +13,7 @@ * * Attempts to log exceptions or abnormal terminations of console commands. * - * @author James Halsall + * @author James Halsall */ class ExceptionListener implements EventSubscriberInterface { @@ -62,10 +62,6 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) return; } - if ($exitCode > 255) { - $event->setExitCode(255); - } - $message = sprintf('Command `%s` exited with status code %d'); $this->logger->warning($message); From 5bd799ee44362f3843f0c4f1366f37425c94d80d Mon Sep 17 00:00:00 2001 From: James Halsall Date: Tue, 9 Aug 2016 19:55:54 +0100 Subject: [PATCH 05/15] Fix onKernelTerminate message logging --- .../Console/EventListener/ExceptionListener.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 98878a7f57c20..fcb2b25492387 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -62,9 +62,15 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) return; } - $message = sprintf('Command `%s` exited with status code %d'); + $message = sprintf( + 'Command `%s` exited with status code %d', + join(' ', $_SERVER['argv']), + $exitCode + ); - $this->logger->warning($message); + $this->logger->error( + $message + ); } public static function getSubscribedEvents() From 80c3ac34aaaeab58b656a8398036784bcce7dea2 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Tue, 9 Aug 2016 19:58:14 +0100 Subject: [PATCH 06/15] Fix coding style --- .../Component/Console/EventListener/ExceptionListener.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index fcb2b25492387..41b3aa04f3d8d 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -64,7 +64,7 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) $message = sprintf( 'Command `%s` exited with status code %d', - join(' ', $_SERVER['argv']), + implode(' ', $_SERVER['argv']), $exitCode ); From f7a7048e18b9ffb87096f77b03e1e16c00216d04 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Wed, 17 Aug 2016 15:46:37 +0100 Subject: [PATCH 07/15] Fix code style --- .../Component/Console/EventListener/ExceptionListener.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 41b3aa04f3d8d..256fc63d88bd7 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -68,9 +68,7 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) $exitCode ); - $this->logger->error( - $message - ); + $this->logger->error($message); } public static function getSubscribedEvents() From c21d2065aed7fb2064704b589d7884abc7cd2a5a Mon Sep 17 00:00:00 2001 From: James Halsall Date: Wed, 17 Aug 2016 15:49:07 +0100 Subject: [PATCH 08/15] Fix code style, add TODO --- .../Component/Console/EventListener/ExceptionListener.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 256fc63d88bd7..1bbb7a73e574a 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -62,11 +62,8 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) return; } - $message = sprintf( - 'Command `%s` exited with status code %d', - implode(' ', $_SERVER['argv']), - $exitCode - ); + // TODO: replace $_SERVER global usage with data from Input + $message = sprintf('Command `%s` exited with status code %d', implode(' ', $_SERVER['argv']), $exitCode); $this->logger->error($message); } From 2874431080164cb93062cdf79f7c8972b5d18039 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Wed, 17 Aug 2016 16:47:10 +0100 Subject: [PATCH 09/15] Update console error log with placeholders and context --- .../Component/Console/EventListener/ExceptionListener.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 1bbb7a73e574a..3d700f4482390 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -62,10 +62,7 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) return; } - // TODO: replace $_SERVER global usage with data from Input - $message = sprintf('Command `%s` exited with status code %d', implode(' ', $_SERVER['argv']), $exitCode); - - $this->logger->error($message); + $this->logger->error('Command `{command}` exited with status code {code}', array('command' => implode(' ', $_SERVER['argv']), 'code' => $exitCode)); } public static function getSubscribedEvents() From bcbc8cbc382d66378d162a6abf8e2cfadb230421 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Wed, 17 Aug 2016 16:50:23 +0100 Subject: [PATCH 10/15] Replace global usage with ArgvInput --- .../Component/Console/EventListener/ExceptionListener.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 3d700f4482390..4b436d4dbd7d8 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -6,6 +6,7 @@ use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; +use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -62,7 +63,9 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) return; } - $this->logger->error('Command `{command}` exited with status code {code}', array('command' => implode(' ', $_SERVER['argv']), 'code' => $exitCode)); + $input = new ArgvInput(null, $event->getCommand()->getDefinition()); + + $this->logger->error('Command `{command}` exited with status code {code}', array('command' => (string) $input, 'code' => $exitCode)); } public static function getSubscribedEvents() From da278e6358eb14c3b94f653ef7a2fddbd65f5240 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Wed, 17 Aug 2016 20:15:07 +0100 Subject: [PATCH 11/15] Remove backticks around command name in log message --- .../Component/Console/EventListener/ExceptionListener.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 4b436d4dbd7d8..a6cd18127008b 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -18,6 +18,9 @@ */ class ExceptionListener implements EventSubscriberInterface { + /** + * @var LoggerInterface + */ protected $logger; /** @@ -65,7 +68,7 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) $input = new ArgvInput(null, $event->getCommand()->getDefinition()); - $this->logger->error('Command `{command}` exited with status code {code}', array('command' => (string) $input, 'code' => $exitCode)); + $this->logger->error('Command {command} exited with status code {code}', array('command' => (string) $input, 'code' => $exitCode)); } public static function getSubscribedEvents() From 44a0822dc2b1f234a886ce62b5dc0f8f61a99513 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Wed, 17 Aug 2016 21:36:42 +0100 Subject: [PATCH 12/15] Add test for onKernelTerminate --- .../EventListener/ExceptionListenerTest.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php diff --git a/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php new file mode 100644 index 0000000000000..b78b6d87921be --- /dev/null +++ b/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php @@ -0,0 +1,44 @@ +getLogger(); + $listener = new ExceptionListener($logger); + + $exception = new \RuntimeException('An error occurred'); + + $logger + ->expects($this->once()) + ->method('error') + ->with('An error occurred', array('exception' => $exception)) + ; + + $listener->onKernelException($this->getConsoleExceptionEvent($exception, 0)); + } + + public function testOnKernelTerminate() + { + $this->markTestIncomplete(); + } + + private function getLogger() + { + return $this->getMockForAbstractClass(LoggerInterface::class); + } + + private function getConsoleExceptionEvent(\Exception $exception, $exitCode) + { + return new ConsoleExceptionEvent(new Command('test'), new ArrayInput([]), new TestOutput(), $exception, $exitCode); + } +} From 5dc8b612979574a29d3a2a28a6291e0dd3fc7b51 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Thu, 18 Aug 2016 19:33:22 +0100 Subject: [PATCH 13/15] Update console ExceptionListener messaging, add test --- .../EventListener/ExceptionListener.php | 13 +++++-- .../EventListener/ExceptionListenerTest.php | 36 ++++++++++++++++--- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index a6cd18127008b..05aff3bd491d5 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -1,12 +1,20 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Console\EventListener; use Psr\Log\LoggerInterface; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleExceptionEvent; use Symfony\Component\Console\Event\ConsoleTerminateEvent; -use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -45,8 +53,9 @@ public function onKernelException(ConsoleExceptionEvent $event) } $exception = $event->getException(); + $input = (string) $event->getInput(); - $this->logger->error($exception->getMessage(), array('exception' => $exception)); + $this->logger->error('Exception thrown while running command: "{command}". Message: "{message}"', array('exception' => $exception, 'command' => $input, 'message' => $exception->getMessage())); } /** diff --git a/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php index b78b6d87921be..d6c168ca4d26a 100644 --- a/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php @@ -1,5 +1,14 @@ + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + namespace Symfony\Component\Console\Tests\EventListener; use Psr\Log\LoggerInterface; @@ -21,10 +30,16 @@ public function testOnKernelException() $logger ->expects($this->once()) ->method('error') - ->with('An error occurred', array('exception' => $exception)) + ->with('Exception thrown while running command: "{command}". Message: "{message}"', array('exception' => $exception, 'command' => '\'test:run\' --foo=baz buzz', 'message' => 'An error occurred')) ; - $listener->onKernelException($this->getConsoleExceptionEvent($exception, 0)); + $input = array( + 'name' => 'test:run', + '--foo' => 'baz', + 'bar' => 'buzz' + ); + + $listener->onKernelException($this->getConsoleExceptionEvent($exception, $input, 0)); } public function testOnKernelTerminate() @@ -32,13 +47,26 @@ public function testOnKernelTerminate() $this->markTestIncomplete(); } + public function testGetSubscribedEvents() + { + $this->assertEquals( + array( + 'console.exception' => array('onKernelException', -128), + 'console.terminate' => array('onKernelTerminate', -128), + ), + ExceptionListener::getSubscribedEvents() + ); + } + private function getLogger() { return $this->getMockForAbstractClass(LoggerInterface::class); } - private function getConsoleExceptionEvent(\Exception $exception, $exitCode) + private function getConsoleExceptionEvent(\Exception $exception, $input, $exitCode) { - return new ConsoleExceptionEvent(new Command('test'), new ArrayInput([]), new TestOutput(), $exception, $exitCode); + $command = new Command('test:run'); + + return new ConsoleExceptionEvent($command, new ArrayInput($input), new TestOutput(), $exception, $exitCode); } } From b196557002f737bbe2ba0dc2be05de3600430804 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Thu, 18 Aug 2016 19:41:53 +0100 Subject: [PATCH 14/15] Add tests for onKernelTerminate, fix log message --- .../EventListener/ExceptionListener.php | 4 +-- .../EventListener/ExceptionListenerTest.php | 36 ++++++++++++++++--- src/Symfony/Component/Console/composer.json | 3 +- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/Console/EventListener/ExceptionListener.php b/src/Symfony/Component/Console/EventListener/ExceptionListener.php index 05aff3bd491d5..afc09c356f4ac 100644 --- a/src/Symfony/Component/Console/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/Console/EventListener/ExceptionListener.php @@ -75,9 +75,9 @@ public function onKernelTerminate(ConsoleTerminateEvent $event) return; } - $input = new ArgvInput(null, $event->getCommand()->getDefinition()); + $input = (string) $event->getInput(); - $this->logger->error('Command {command} exited with status code {code}', array('command' => (string) $input, 'code' => $exitCode)); + $this->logger->error('Command "{command}" exited with status code "{code}"', array('command' => (string) $input, 'code' => $exitCode)); } public static function getSubscribedEvents() diff --git a/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php index d6c168ca4d26a..76c414e935205 100644 --- a/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/Console/Tests/EventListener/ExceptionListenerTest.php @@ -14,6 +14,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Event\ConsoleExceptionEvent; +use Symfony\Component\Console\Event\ConsoleTerminateEvent; use Symfony\Component\Console\EventListener\ExceptionListener; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Tests\Output\TestOutput; @@ -39,12 +40,34 @@ public function testOnKernelException() 'bar' => 'buzz' ); - $listener->onKernelException($this->getConsoleExceptionEvent($exception, $input, 0)); + $listener->onKernelException($this->getConsoleExceptionEvent($exception, $input, 1)); } - public function testOnKernelTerminate() + public function testOnKernelTerminateForNonZeroExitCodeWritesToLog() { - $this->markTestIncomplete(); + $logger = $this->getLogger(); + $listener = new ExceptionListener($logger); + + $logger + ->expects($this->once()) + ->method('error') + ->with('Command "{command}" exited with status code "{code}"', array('command' => '\'test:run\'', 'code' => 255)) + ; + + $listener->onKernelTerminate($this->getConsoleTerminateEvent(array('name' => 'test:run'), 255)); + } + + public function testOnKernelTerminateForZeroExitCodeDoesNotWriteToLog() + { + $logger = $this->getLogger(); + $listener = new ExceptionListener($logger); + + $logger + ->expects($this->never()) + ->method('error') + ; + + $listener->onKernelTerminate($this->getConsoleTerminateEvent(array('name' => 'test:run'), 0)); } public function testGetSubscribedEvents() @@ -65,8 +88,11 @@ private function getLogger() private function getConsoleExceptionEvent(\Exception $exception, $input, $exitCode) { - $command = new Command('test:run'); + return new ConsoleExceptionEvent(new Command('test:run'), new ArrayInput($input), new TestOutput(), $exception, $exitCode); + } - return new ConsoleExceptionEvent($command, new ArrayInput($input), new TestOutput(), $exception, $exitCode); + private function getConsoleTerminateEvent($input, $exitCode) + { + return new ConsoleTerminateEvent(new Command('test:run'), new ArrayInput($input), new TestOutput(), $exitCode); } } diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index cb73a00b8d887..d5f00bb2370dd 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -23,7 +23,8 @@ "symfony/event-dispatcher": "~2.8|~3.0", "symfony/filesystem": "~2.8|~3.0", "symfony/process": "~2.8|~3.0", - "psr/log": "~1.0" + "psr/log": "~1.0", + "phpunit/phpunit": "~4.0" }, "suggest": { "symfony/event-dispatcher": "", From e6c4994066deca66e09f8a861fbb25a7b6f87777 Mon Sep 17 00:00:00 2001 From: James Halsall Date: Thu, 18 Aug 2016 19:43:42 +0100 Subject: [PATCH 15/15] Revert change to composer.json --- src/Symfony/Component/Console/composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Symfony/Component/Console/composer.json b/src/Symfony/Component/Console/composer.json index d5f00bb2370dd..cb73a00b8d887 100644 --- a/src/Symfony/Component/Console/composer.json +++ b/src/Symfony/Component/Console/composer.json @@ -23,8 +23,7 @@ "symfony/event-dispatcher": "~2.8|~3.0", "symfony/filesystem": "~2.8|~3.0", "symfony/process": "~2.8|~3.0", - "psr/log": "~1.0", - "phpunit/phpunit": "~4.0" + "psr/log": "~1.0" }, "suggest": { "symfony/event-dispatcher": "",