From 915a428973366e81ca524c0c7963fb22e36bd1b4 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Fri, 3 Apr 2020 13:38:54 -0400 Subject: [PATCH] Add console extender (#2057) * Made the console command system extender-friendly * Added console extender * Added ConsoleTestCase to integration tests * Added integration tests for console extender * Marked event-based console extension system as deprecated * Moved trimming command output of whitespace into superclass * Renamed 'add' to 'command' * Added special processing for laravel commands * Code style fixes * More style fixes * Fixed $this->container --- .../tests/integration/ConsoleTestCase.php | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 php-packages/testing/tests/integration/ConsoleTestCase.php diff --git a/php-packages/testing/tests/integration/ConsoleTestCase.php b/php-packages/testing/tests/integration/ConsoleTestCase.php new file mode 100644 index 000000000..80d907a2e --- /dev/null +++ b/php-packages/testing/tests/integration/ConsoleTestCase.php @@ -0,0 +1,44 @@ +console)) { + $this->console = new ConsoleApplication('Flarum', Application::VERSION); + $this->console->setAutoExit(false); + + foreach ($this->app()->getConsoleCommands() as $command) { + $this->console->add($command); + } + } + + return $this->console; + } + + protected function runCommand(array $inputArray) + { + $input = new ArrayInput($inputArray); + $output = new BufferedOutput(); + + $this->console()->run($input, $output); + + return trim($output->fetch()); + } +}