You are here

public function DbDumpCommandTest::testSchemaOnly in Zircon Profile 8

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

Test schema only option.

File

core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php, line 65
Contains \Drupal\Tests\system\Kernel\Scripts\DbDumpCommandTest.

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
    ->assertContains("createTable('router", $output, 'Table router found');
  $this
    ->assertNotContains("insert('router", $output, 'Insert not found');
  $this
    ->assertNotContains("'name' => 'test", $output, 'Insert name field not found');
  $this
    ->assertNotContains("'path' => 'test", $output, 'Insert path field not found');
  $this
    ->assertNotContains("'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
    ->assertContains("createTable('router", $output, 'Table router found');
  $this
    ->assertNotContains("insert('router", $output, 'Insert not found');
  $this
    ->assertNotContains("'name' => 'test", $output, 'Insert name field not found');
  $this
    ->assertNotContains("'path' => 'test", $output, 'Insert path field not found');
  $this
    ->assertNotContains("'pattern_outline' => 'test", $output, 'Insert pattern_outline field not found');
}