public function DbDumpTest::testDbDumpCommand in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::testDbDumpCommand()
- 9 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::testDbDumpCommand()
Tests the command directly.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Command/ DbDumpTest.php, line 151
Class
- DbDumpTest
- Tests for the database dump commands.
Namespace
Drupal\KernelTests\Core\CommandCode
public function testDbDumpCommand() {
$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.');
}