public function DbDumpTest::testDbDumpCommand in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Update/DbDumpTest.php \Drupal\system\Tests\Update\DbDumpTest::testDbDumpCommand()
Test the command directly.
File
- core/
modules/ system/ src/ Tests/ Update/ DbDumpTest.php, line 148 - Contains \Drupal\system\Tests\Update\DbDumpTest.
Class
- DbDumpTest
- Tests for the database dump commands.
Namespace
Drupal\system\Tests\UpdateCode
public function testDbDumpCommand() {
if ($this->skipTests) {
$this
->pass("Skipping test since the DbDumpCommand is currently only compatible with MySql");
return;
}
$application = new DbDumpApplication();
$command = $application
->find('dump-database-d8-mysql');
$command_tester = new CommandTester($command);
$command_tester
->execute([]);
// Tables that are schema-only should not have data exported.
$pattern = preg_quote("\$connection->insert('sessions')");
$this
->assertFalse(preg_match('/' . $pattern . '/', $command_tester
->getDisplay()), 'Tables defined as schema-only do not have data exported to the script.');
// Table data is exported.
$pattern = preg_quote("\$connection->insert('config')");
$this
->assertTrue(preg_match('/' . $pattern . '/', $command_tester
->getDisplay()), 'Table data is properly exported to the script.');
// The test data are in the dump (serialized).
$pattern = preg_quote(serialize($this->data));
$this
->assertTrue(preg_match('/' . $pattern . '/', $command_tester
->getDisplay()), 'Generated data is found in the exported script.');
// Check that the user account name and email address was properly escaped.
$pattern = preg_quote('"q\'uote\\$dollar@example.com"');
$this
->assertTrue(preg_match('/' . $pattern . '/', $command_tester
->getDisplay()), 'The user account email address was properly escaped in the exported script.');
$pattern = preg_quote('\'$dollar\'');
$this
->assertTrue(preg_match('/' . $pattern . '/', $command_tester
->getDisplay()), 'The user account name was properly escaped in the exported script.');
}