diff --git a/core/lib/Drupal/Core/Command/DbDumpCommand.php b/core/lib/Drupal/Core/Command/DbDumpCommand.php index fd828b8..3c0d5c4 100644 --- a/core/lib/Drupal/Core/Command/DbDumpCommand.php +++ b/core/lib/Drupal/Core/Command/DbDumpCommand.php @@ -21,6 +21,10 @@ * for tables denoted as schema-only). The resulting script creates the tables * and populates them with the exported data. * + * This command is currently only compatible with MySQL. Making it backend- + * agnostic will require \Drupal\Core\Database\Schema support the ability + * to retrieve table schema information. + * * @see \Drupal\Core\Command\DbDumpApplication */ class DbDumpCommand extends Command { diff --git a/core/modules/system/src/Tests/Update/DbDumpTest.php b/core/modules/system/src/Tests/Update/DbDumpTest.php index f9fc7e3..f07522a 100644 --- a/core/modules/system/src/Tests/Update/DbDumpTest.php +++ b/core/modules/system/src/Tests/Update/DbDumpTest.php @@ -6,10 +6,12 @@ */ namespace Drupal\system\Tests\Update; + use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Command\DbDumpApplication; use Drupal\Core\Config\DatabaseStorage; use Drupal\Core\Database\Database; +use Drupal\Core\Database\Driver\mysql\Connection; use Drupal\simpletest\KernelTestBase; use Symfony\Component\Console\Tester\CommandTester; @@ -33,6 +35,15 @@ class DbDumpTest extends KernelTestBase { protected $data; /** + * Flag to skip these tests, which are database-backend dependent (MySQL). + * + * @see \Drupal\Core\Command\DbDumpCommand + * + * @var bool + */ + protected $skipTests = FALSE; + + /** * {@inheritdoc} */ public function setUp() { @@ -45,12 +56,20 @@ public function setUp() { $this->data = ['foo' => $this->randomMachineName(), 'bar' => $this->randomMachineName()]; $storage = new DatabaseStorage(Database::getConnection(), 'config'); $storage->write('test_config', $this->data); + + // Determine what database backend is running, and set the skip flag. + $this->skipTests = !(Database::getConnection() instanceof Connection); } /** * Test the command directly. */ public function testDbDumpCommand() { + if ($this->skipTests) { + $this->pass("Skipping test since the DbDumpCommand is currently only compatible with MySql"); + return; + } + $application = new DbDumpApplication(Database::getConnection(), $this->container->get('module_handler')); $command = $application->find('dump-database-d8'); $command_tester = new CommandTester($command); @@ -83,6 +102,11 @@ public function testDbDumpCommand() { * Test loading the script back into the database. */ public function testScriptLoad() { + if ($this->skipTests) { + $this->pass("Skipping test since the DbDumpCommand is currently only compatible with MySql"); + return; + } + // Generate the script. $application = new DbDumpApplication(Database::getConnection(), $this->container->get('module_handler')); $command = $application->find('dump-database-d8');