You are here

public function DbDumpCommandTest::testSchemaOnly 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::testSchemaOnly()
  2. 9 core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php \Drupal\Tests\system\Kernel\Scripts\DbDumpCommandTest::testSchemaOnly()

Tests schema only option.

File

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

Class

DbDumpCommandTest
Test that the DbDumpCommand works correctly.

Namespace

Drupal\Tests\system\Kernel\Scripts

Code

public function testSchemaOnly() {
  $command = new DbDumpCommand();
  $command_tester = new CommandTester($command);
  $command_tester
    ->execute([
    '--schema-only' => 'router',
  ]);

  // Assert that insert statement doesn't exist for schema only table.
  $output = $command_tester
    ->getDisplay();
  $this
    ->assertStringContainsString("createTable('router", $output, 'Table router found');
  $this
    ->assertStringNotContainsString("insert('router", $output, 'Insert not found');
  $this
    ->assertStringNotContainsString("'name' => 'test", $output, 'Insert name field not found');
  $this
    ->assertStringNotContainsString("'path' => 'test", $output, 'Insert path field not found');
  $this
    ->assertStringNotContainsString("'pattern_outline' => 'test", $output, 'Insert pattern_outline field not found');

  // Assert that insert statement doesn't exist for wildcard schema only match.
  $command_tester
    ->execute([
    '--schema-only' => 'route.*',
  ]);
  $output = $command_tester
    ->getDisplay();
  $this
    ->assertStringContainsString("createTable('router", $output, 'Table router found');
  $this
    ->assertStringNotContainsString("insert('router", $output, 'Insert not found');
  $this
    ->assertStringNotContainsString("'name' => 'test", $output, 'Insert name field not found');
  $this
    ->assertStringNotContainsString("'path' => 'test", $output, 'Insert path field not found');
  $this
    ->assertStringNotContainsString("'pattern_outline' => 'test", $output, 'Insert pattern_outline field not found');
}