function DbDumpCommandTest::testDbDumpCommand

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

Tests the command directly.

File

core/modules/mysql/tests/src/Kernel/mysql/Console/DbDumpCommandTest.php, line 46

Class

DbDumpCommandTest
Test that the DbDumpCommand works correctly.

Namespace

Drupal\Tests\mysql\Kernel\mysql\Console

Code

public function testDbDumpCommand() : void {
    $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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.