function DbDumpTest::testDbDumpCommand
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::testDbDumpCommand()
- 8.9.x core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::testDbDumpCommand()
- 10 core/modules/mysql/tests/src/Kernel/mysql/DbDumpTest.php \Drupal\Tests\mysql\Kernel\mysql\DbDumpTest::testDbDumpCommand()
Tests the command directly.
File
-
core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ DbDumpTest.php, line 149
Class
- DbDumpTest
- Tests for the database dump commands.
Namespace
Drupal\Tests\mysql\Kernel\mysqlCode
public function testDbDumpCommand() : void {
$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->assertDoesNotMatchRegularExpression('/' . $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->assertMatchesRegularExpression('/' . $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->assertMatchesRegularExpression('/' . $pattern . '/', $command_tester->getDisplay(), 'Generated data is found in the exported script.');
// Check that the user account name and email address was properly escaped.
// cspell:disable-next-line
$pattern = preg_quote('"q\'uote\\$dollar@example.com"');
$this->assertMatchesRegularExpression('/' . $pattern . '/', $command_tester->getDisplay(), 'The user account email address was properly escaped in the exported script.');
$pattern = preg_quote('\'$dollar\'');
$this->assertMatchesRegularExpression('/' . $pattern . '/', $command_tester->getDisplay(), 'The user account name was properly escaped in the exported script.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.