diff --git a/core/lib/Drupal/Core/Command/DbCommandBase.php b/core/lib/Drupal/Core/Command/DbCommandBase.php index d36fde4..bd401d8 100644 --- a/core/lib/Drupal/Core/Command/DbCommandBase.php +++ b/core/lib/Drupal/Core/Command/DbCommandBase.php @@ -39,7 +39,7 @@ protected function getDatabaseConnection(InputInterface $input) { // @todo this could probably be refactored to not use a global connection. // Ensure database connection isn't set. if (Database::getConnectionInfo('db-tools')) { - throw new \RuntimeException('Database "db-tools" is already defined. Can not define database provided.'); + throw new \RuntimeException('Database "db-tools" is already defined. Cannot define database provided.'); } $info = Database::convertDbUrlToConnectionInfo($input->getOption('database-url'), \Drupal::root()); Database::addConnectionInfo('db-tools', 'default', $info); diff --git a/core/lib/Drupal/Core/Command/DbImportCommand.php b/core/lib/Drupal/Core/Command/DbImportCommand.php index 6ce6ee5..de41089 100644 --- a/core/lib/Drupal/Core/Command/DbImportCommand.php +++ b/core/lib/Drupal/Core/Command/DbImportCommand.php @@ -53,10 +53,9 @@ protected function execute(InputInterface $input, OutputInterface $output) { * Run the database script. * * @param \Drupal\Core\Database\Connection $connection - * ... + * Connection used by the script when included. * @param string $script - * The PHP script. - * @return mixed + * Path to dump script. */ protected function runScript(Connection $connection, $script) { if (substr($script, -3) == '.gz') { diff --git a/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php b/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php index d5f1ade..c11770d 100644 --- a/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php +++ b/core/modules/system/tests/src/Kernel/Scripts/DbCommandBaseTest.php @@ -78,6 +78,10 @@ public function testSpecifyDbUrl() { * Test specifying a prefix for different connections. */ public function testPrefix() { + if (Database::getConnection()->driver() == 'sqlite') { + $this->markTestSkipped('SQLITE modifies the prefixes so we cannot effectively test it'); + } + Database::addConnectionInfo('magic_db', 'default', Database::getConnectionInfo('default')['default']); $command = new DbCommandBaseTester(); $command_tester = new CommandTester($command); diff --git a/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php b/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php index 5e1e538..a326494 100644 --- a/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php +++ b/core/modules/system/tests/src/Kernel/Scripts/DbDumpCommandTest.php @@ -32,7 +32,7 @@ public function setUp() { // Determine what database backend is running, and set the skip flag. if (Database::getConnection()->databaseType() !== 'mysql') { - $this->markTestSkipped("Skipping test since the DbDumpCommand is currently only compatible with MySql"); + $this->markTestSkipped("Skipping test since the DbDumpCommand is currently only compatible with MySQL"); } $this->installSchema('system', 'router'); @@ -50,12 +50,13 @@ public function testDbDumpCommand() { $command_tester = new CommandTester($command); $command_tester->execute([]); + // Assert that insert exists and that some expected fields exist. $output = $command_tester->getDisplay(); $this->assertTrue(strpos($output, "createTable('router"), 'Table router found'); $this->assertTrue(strpos($output, "insert('router"), 'Insert found'); $this->assertTrue(strpos($output, "'name' => 'test"), 'Insert name field found'); $this->assertTrue(strpos($output, "'path' => 'test"), 'Insert path field found'); - $this->assertTrue(strpos($output, "'pattern_outline' => 'test"), 'Insert pattern_outline'); + $this->assertTrue(strpos($output, "'pattern_outline' => 'test"), 'Insert pattern_outline field found'); } /** @@ -66,20 +67,22 @@ public function testSchemaOnly() { $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->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'); + $this->assertFalse(strpos($output, "insert('router"), 'Insert not found'); + $this->assertFalse(strpos($output, "'name' => 'test"), 'Insert name field not found'); + $this->assertFalse(strpos($output, "'path' => 'test"), 'Insert path field not found'); + $this->assertFalse(strpos($output, "'pattern_outline' => 'test"), '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->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'); + $this->assertFalse(strpos($output, "insert('router"), 'Insert not found'); + $this->assertFalse(strpos($output, "'name' => 'test"), 'Insert name field not found'); + $this->assertFalse(strpos($output, "'path' => 'test"), 'Insert path field not found'); + $this->assertFalse(strpos($output, "'pattern_outline' => 'test"), 'Insert pattern_outline field not found'); } }