Initial
This commit is contained in:
21
tests/_support/Commands/AbstractInfo.php
Normal file
21
tests/_support/Commands/AbstractInfo.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Support\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
|
||||
abstract class AbstractInfo extends BaseCommand
|
||||
{
|
||||
protected $group = 'demo';
|
||||
protected $name = 'app:pablo';
|
||||
protected $description = 'Displays basic application information.';
|
||||
}
|
||||
44
tests/_support/Commands/AppInfo.php
Normal file
44
tests/_support/Commands/AppInfo.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Support\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use CodeIgniter\CodeIgniter;
|
||||
use RuntimeException;
|
||||
|
||||
class AppInfo extends BaseCommand
|
||||
{
|
||||
protected $group = 'demo';
|
||||
protected $name = 'app:info';
|
||||
protected $arguments = ['draft' => 'unused'];
|
||||
protected $description = 'Displays basic application information.';
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red'));
|
||||
}
|
||||
|
||||
public function bomb()
|
||||
{
|
||||
try {
|
||||
CLI::color('test', 'white', 'Background');
|
||||
} catch (RuntimeException $oops) {
|
||||
$this->showError($oops);
|
||||
}
|
||||
}
|
||||
|
||||
public function helpme()
|
||||
{
|
||||
$this->call('help');
|
||||
}
|
||||
}
|
||||
11
tests/_support/Commands/Foobar.php
Normal file
11
tests/_support/Commands/Foobar.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
use Config\App;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
return [
|
||||
'foo' => 'The command will use this as foo.',
|
||||
'bar' => 'The command will use this as bar.',
|
||||
'baz' => 'The baz is here.',
|
||||
'bas' => CLI::color('bas', 'green') . (new App())->baseURL,
|
||||
];
|
||||
34
tests/_support/Commands/InvalidCommand.php
Normal file
34
tests/_support/Commands/InvalidCommand.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Support\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\CLI;
|
||||
use CodeIgniter\CodeIgniter;
|
||||
use ReflectionException;
|
||||
|
||||
class InvalidCommand extends BaseCommand
|
||||
{
|
||||
protected $group = 'demo';
|
||||
protected $name = 'app:invalid';
|
||||
protected $description = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
throw new ReflectionException();
|
||||
}
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red'));
|
||||
}
|
||||
}
|
||||
49
tests/_support/Commands/LanguageCommand.php
Normal file
49
tests/_support/Commands/LanguageCommand.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Support\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\GeneratorTrait;
|
||||
|
||||
class LanguageCommand extends BaseCommand
|
||||
{
|
||||
use GeneratorTrait;
|
||||
|
||||
protected $group = 'Generators';
|
||||
protected $name = 'publish:language';
|
||||
protected $description = 'Publishes a language file.';
|
||||
protected $usage = 'publish:language [options]';
|
||||
protected $options = [
|
||||
'--lang' => 'The language folder to save the file.',
|
||||
'--sort' => 'Turn on/off the sortImports flag.',
|
||||
];
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
$this->setHasClassName(false);
|
||||
$params[0] = 'Foobar';
|
||||
$params['lang'] = $params['lang'] ?? 'en';
|
||||
|
||||
$this->component = 'Language';
|
||||
$this->directory = 'Language\\' . $params['lang'];
|
||||
|
||||
$sort = (isset($params['sort']) && $params['sort'] === 'off') ? false : true;
|
||||
$this->setSortImports($sort);
|
||||
|
||||
$this->execute($params);
|
||||
}
|
||||
|
||||
protected function prepare(string $class): string
|
||||
{
|
||||
return file_get_contents(__DIR__ . '/Foobar.php') ?: '';
|
||||
}
|
||||
}
|
||||
28
tests/_support/Commands/ParamsReveal.php
Normal file
28
tests/_support/Commands/ParamsReveal.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Support\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
|
||||
class ParamsReveal extends BaseCommand
|
||||
{
|
||||
protected $group = 'demo';
|
||||
protected $name = 'reveal';
|
||||
protected $usage = 'reveal [options] [arguments]';
|
||||
protected $description = 'Reveal params';
|
||||
public static $args;
|
||||
|
||||
public function run(array $params)
|
||||
{
|
||||
static::$args = $params;
|
||||
}
|
||||
}
|
||||
77
tests/_support/Commands/Unsuffixable.php
Normal file
77
tests/_support/Commands/Unsuffixable.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of CodeIgniter 4 framework.
|
||||
*
|
||||
* (c) CodeIgniter Foundation <admin@codeigniter.com>
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Tests\Support\Commands;
|
||||
|
||||
use CodeIgniter\CLI\BaseCommand;
|
||||
use CodeIgniter\CLI\GeneratorTrait;
|
||||
|
||||
class Unsuffixable extends BaseCommand
|
||||
{
|
||||
use GeneratorTrait;
|
||||
|
||||
/**
|
||||
* The Command's Group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $group = 'Generators';
|
||||
|
||||
/**
|
||||
* The Command's Name
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name = 'make:foo';
|
||||
|
||||
/**
|
||||
* The Command's Description
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = '';
|
||||
|
||||
/**
|
||||
* The Command's Usage
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $usage = 'make:foo [arguments] [options]';
|
||||
|
||||
/**
|
||||
* The Command's Arguments
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $arguments = [
|
||||
'name' => 'Class name',
|
||||
];
|
||||
|
||||
/**
|
||||
* The Command's Options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Actually execute a command.
|
||||
*/
|
||||
public function run(array $params)
|
||||
{
|
||||
$this->component = 'Command';
|
||||
$this->directory = 'Commands';
|
||||
$this->template = 'command.tpl.php';
|
||||
|
||||
$this->setEnabledSuffixing(false);
|
||||
$this->execute($params);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user