function DevelHookCommandTest::testDrushCompatibility

Drush 13 and 14 load the subclass in the old namespace.

File

tests/src/Kernel/DevelHookCommandTest.php, line 104

Class

DevelHookCommandTest
Tests the devel:hook command.

Namespace

Drupal\Tests\devel\Kernel

Code

public function testDrushCompatibility() : void {
  if (!trait_exists(AutowireTrait::class)) {
    $this->markTestSkipped('Drush is not installed.');
  }
  // This is how Drush builds a command from an invokable class.
  $command = new Command(NULL, DrushDevelHookCommand::create($this->container));
  $this->assertSame(DevelHookCommand::NAME, $command->getName());
  $this->assertContains('fn-hook', $command->getAliases());
  $tester = new CommandTester($command);
  $tester->execute([
    'hook' => 'help',
    'implementation' => 'devel',
  ], [
    'interactive' => FALSE,
  ]);
  $method = new \ReflectionMethod(DevelHooks::class, 'help');
  $this->assertSame($method->getFileName() . ':' . $method->getStartLine(), trim($tester->getDisplay()));
}