function GenerateCommandsKernelTest::testDrushCompatibility
Drush 13 and 14 load the subclasses in the old namespace.
Attributes
#[DataProvider('commands')]
File
-
devel_generate/
tests/ src/ Kernel/ GenerateCommandsKernelTest.php, line 106
Class
- GenerateCommandsKernelTest
- Tests the devel_generate commands.
Namespace
Drupal\Tests\devel_generate\KernelCode
public function testDrushCompatibility(string $class, array $aliases) : void {
if (!trait_exists(AutowireTrait::class)) {
$this->markTestSkipped('Drush is not installed.');
}
// This is how Drush builds a command from an invokable class.
$drush_class = str_replace('\\Command\\', '\\Drush\\Commands\\', $class);
$command = new Command(NULL, $drush_class::create($this->container));
$this->assertSame($class::NAME, $command->getName());
$this->assertSame([], array_diff($aliases, $command->getAliases()));
// The definition matches that of the dr command.
$expected = new Command(NULL, $this->container
->get($class));
$this->assertEquals($expected->getDefinition(), $command->getDefinition());
}