mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
e46135be0a
- Turn sake into a symfony/console app - Avoid using HTTPRequest for CLI interaction - Implement abstract hybrid execution path
32 lines
855 B
PHP
32 lines
855 B
PHP
<?php
|
|
|
|
namespace SilverStripe\Cli\Tests\SakeTest;
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
|
|
use Symfony\Component\Console\Exception\CommandNotFoundException;
|
|
|
|
class TestCommandLoader implements CommandLoaderInterface, TestOnly
|
|
{
|
|
private string $commandName = 'loader:test-command';
|
|
|
|
public function get(string $name): Command
|
|
{
|
|
if ($name !== $this->commandName) {
|
|
throw new CommandNotFoundException("Wrong command fetched. Expected '$this->commandName' - got '$name'");
|
|
}
|
|
return new TestLoaderCommand();
|
|
}
|
|
|
|
public function has(string $name): bool
|
|
{
|
|
return $name === $this->commandName;
|
|
}
|
|
|
|
public function getNames(): array
|
|
{
|
|
return [$this->commandName];
|
|
}
|
|
}
|