diff --git a/core/lib/Drupal/Core/Command/DbDumpCommand.php b/core/lib/Drupal/Core/Command/DbDumpCommand.php index 18d36e8..95e9906 100644 --- a/core/lib/Drupal/Core/Command/DbDumpCommand.php +++ b/core/lib/Drupal/Core/Command/DbDumpCommand.php @@ -82,7 +82,7 @@ protected function generateScript(Connection $connection, array $schema_only = [ $schema_only_patterns = []; foreach ($schema_only as $match) { - $schema_only_patterns[] = '/^' . preg_quote($match) . '$/'; + $schema_only_patterns[] = '/^' . $match . '$/'; } foreach ($this->getTables($connection) as $table) { diff --git a/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php b/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php index 4fe9b37..5e1e538 100644 --- a/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php +++ b/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php @@ -58,6 +58,9 @@ public function testDbDumpCommand() { $this->assertTrue(strpos($output, "'pattern_outline' => 'test"), 'Insert pattern_outline'); } + /** + * Test schema only option. + */ public function testSchemaOnly() { $command = new DbDumpCommand(); $command_tester = new CommandTester($command); @@ -69,6 +72,14 @@ public function testSchemaOnly() { $this->assertFalse(strpos($output, "'name' => 'test"), 'Insert name field found'); $this->assertFalse(strpos($output, "'path' => 'test"), 'Insert path field found'); $this->assertFalse(strpos($output, "'pattern_outline' => 'test"), 'Insert pattern_outline'); + + $command_tester->execute(['--schema-only' => 'route.*']); + $output = $command_tester->getDisplay(); + $this->assertTrue(strpos($output, "createTable('router"), 'Table router found'); + $this->assertFalse(strpos($output, "insert('router"), 'Insert found'); + $this->assertFalse(strpos($output, "'name' => 'test"), 'Insert name field found'); + $this->assertFalse(strpos($output, "'path' => 'test"), 'Insert path field found'); + $this->assertFalse(strpos($output, "'pattern_outline' => 'test"), 'Insert pattern_outline'); } }