diff --git a/tests/system/Commands/CommandTest.php b/tests/system/Commands/CommandTest.php deleted file mode 100644 index a37bb3d1a380..000000000000 --- a/tests/system/Commands/CommandTest.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace CodeIgniter\Commands; - -use CodeIgniter\CLI\Commands; -use CodeIgniter\Log\Logger; -use CodeIgniter\Test\CIUnitTestCase; -use CodeIgniter\Test\StreamFilterTrait; -use PHPUnit\Framework\Attributes\Group; -use Tests\Support\Commands\AppInfo; - -/** - * @internal - */ -#[Group('Others')] -final class CommandTest extends CIUnitTestCase -{ - use StreamFilterTrait; - - private Logger $logger; - private Commands $commands; - - protected function setUp(): void - { - $this->resetServices(); - - parent::setUp(); - - $this->logger = service('logger'); - $this->commands = service('commands'); - } - - protected function getBuffer(): string - { - return $this->getStreamFilterBuffer(); - } - - public function testListCommands(): void - { - command('list'); - - // make sure the result looks like a command list - $this->assertStringContainsString('Lists the available commands.', $this->getBuffer()); - $this->assertStringContainsString('Displays basic usage information.', $this->getBuffer()); - } - - public function testListCommandsSimple(): void - { - command('list --simple'); - - $this->assertStringContainsString('db:seed', $this->getBuffer()); - $this->assertStringNotContainsString('Lists the available commands.', $this->getBuffer()); - } - - public function testCustomCommand(): void - { - command('app:info'); - $this->assertStringContainsString('CodeIgniter Version:', $this->getBuffer()); - } - - public function testShowError(): void - { - command('app:info'); - $commands = $this->commands->getCommands(); - - /** @var AppInfo */ - $command = new $commands['app:info']['class']($this->logger, $this->commands); - - $command->helpMe(); - - $this->assertStringContainsString('Displays basic usage information.', $this->getBuffer()); - } - - public function testCommandCall(): void - { - command('app:info'); - $commands = $this->commands->getCommands(); - - /** @var AppInfo */ - $command = new $commands['app:info']['class']($this->logger, $this->commands); - - $command->bomb(); - - $this->assertStringContainsString('Invalid "background" color:', $this->getBuffer()); - } - - public function testAbstractCommand(): void - { - command('app:pablo'); - $this->assertStringContainsString('not found', $this->getBuffer()); - } - - public function testNamespacesCommand(): void - { - command('namespaces'); - - $this->assertStringContainsString('| Namespace', $this->getBuffer()); - $this->assertStringContainsString('| Config', $this->getBuffer()); - $this->assertStringContainsString('| Yes', $this->getBuffer()); - } - - public function testInexistentCommandWithNoAlternatives(): void - { - command('app:oops'); - $this->assertStringContainsString('Command "app:oops" not found', $this->getBuffer()); - } - - public function testInexistentCommandsButWithOneAlternative(): void - { - command('namespace'); - - $this->assertStringContainsString('Command "namespace" not found.', $this->getBuffer()); - $this->assertStringContainsString('Did you mean this?', $this->getBuffer()); - $this->assertStringContainsString('namespaces', $this->getBuffer()); - } - - public function testInexistentCommandsButWithManyAlternatives(): void - { - command('clear'); - - $this->assertStringContainsString('Command "clear" not found.', $this->getBuffer()); - $this->assertStringContainsString('Did you mean one of these?', $this->getBuffer()); - $this->assertStringContainsString(':clear', $this->getBuffer()); - } -}