mirror of
https://github.com/flarum/framework.git
synced 2024-11-27 11:03:37 +08:00
345ad4bc6d
* 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
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?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());
|
|
}
|
|
}
|