You are here

public function DbDumpCommandTest::testDbDumpCommand in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbDumpCommandTest::testDbDumpCommand()
  2. 9 core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbDumpCommandTest::testDbDumpCommand()

Tests the command directly.

File

core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php, line 50

Class

DbDumpCommandTest
Test that the DbDumpCommand works correctly.

Namespace

Drupal\Tests\system\Kernel\Scripts

Code

public function testDbDumpCommand() {
  $command = new DbDumpCommand();
  $command_tester = new CommandTester($command);
  $command_tester
    ->execute([]);

  // Assert that insert exists and that some expected fields exist.
  $output = $command_tester
    ->getDisplay();
  $this
    ->assertStringContainsString("createTable('router", $output, 'Table router found');
  $this
    ->assertStringContainsString("insert('router", $output, 'Insert found');
  $this
    ->assertStringContainsString("'name' => 'test", $output, 'Insert name field found');
  $this
    ->assertStringContainsString("'path' => 'test", $output, 'Insert path field found');
  $this
    ->assertStringContainsString("'pattern_outline' => 'test", $output, 'Insert pattern_outline field found');
  $this
    ->assertStringContainsString("// phpcs:ignoreFile", $output);
  $version = \Drupal::VERSION;
  $this
    ->assertStringContainsString("This file was generated by the Drupal {$version} db-tools.php script.", $output);
}