mirror of
https://github.com/flarum/core.git
synced 2025-07-30 21:20:24 +02:00
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
This commit is contained in:
committed by
Alexander Skvortsov
parent
21f4c3f6dd
commit
915a428973
44
php-packages/testing/tests/integration/ConsoleTestCase.php
Normal file
44
php-packages/testing/tests/integration/ConsoleTestCase.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* For detailed copyright and license information, please view the
|
||||
* LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Tests\integration;
|
||||
|
||||
use Flarum\Foundation\Application;
|
||||
use Symfony\Component\Console\Application as ConsoleApplication;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
abstract class ConsoleTestCase extends TestCase
|
||||
{
|
||||
protected $console;
|
||||
|
||||
protected function console()
|
||||
{
|
||||
if (is_null($this->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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user