protected function DbDumpTest::setUp in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::setUp()
- 10 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::setUp()
Overrides KernelTestBase::setUp
File
- core/
tests/ Drupal/ KernelTests/ Core/ Command/ DbDumpTest.php, line 84
Class
- DbDumpTest
- Tests for the database dump commands.
Namespace
Drupal\KernelTests\Core\CommandCode
protected function setUp() {
parent::setUp();
if (Database::getConnection()
->databaseType() !== 'mysql') {
$this
->markTestSkipped("Skipping test since the DbDumpCommand is currently only compatible with MySql");
}
// Create some schemas so our export contains tables.
$this
->installSchema('system', [
'key_value_expire',
'sessions',
]);
$this
->installSchema('dblog', [
'watchdog',
]);
$this
->installEntitySchema('block_content');
$this
->installEntitySchema('user');
$this
->installEntitySchema('file');
$this
->installEntitySchema('menu_link_content');
$this
->installEntitySchema('path_alias');
$this
->installSchema('system', 'sequences');
// Place some sample config to test for in the export.
$this->data = [
'foo' => $this
->randomMachineName(),
'bar' => $this
->randomMachineName(),
];
$storage = new DatabaseStorage(Database::getConnection(), 'config');
$storage
->write('test_config', $this->data);
// Create user account with some potential syntax issues.
$account = User::create([
'mail' => 'q\'uote$dollar@example.com',
'name' => '$dollar',
]);
$account
->save();
// Create a path alias.
$this
->createPathAlias('/user/' . $account
->id(), '/user/example');
// Create a cache table (this will create 'cache_discovery').
\Drupal::cache('discovery')
->set('test', $this->data);
// These are all the tables that should now be in place.
$this->tables = [
'block_content',
'block_content_field_data',
'block_content_field_revision',
'block_content_revision',
'cachetags',
'config',
'cache_bootstrap',
'cache_config',
'cache_data',
'cache_discovery',
'cache_entity',
'file_managed',
'key_value_expire',
'menu_link_content',
'menu_link_content_data',
'menu_link_content_revision',
'menu_link_content_field_revision',
'sequences',
'sessions',
'path_alias',
'path_alias_revision',
'user__roles',
'users',
'users_field_data',
'watchdog',
];
}