function DbDumpCommandTest::testSchemaOnly

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

Tests schema only option.

File

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

Class

DbDumpCommandTest
Test that the DbDumpCommand works correctly.

Namespace

Drupal\Tests\mysql\Kernel\mysql\Console

Code

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

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