function DbDumpTest::setUp

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::setUp()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Command/DbDumpTest.php \Drupal\KernelTests\Core\Command\DbDumpTest::setUp()
  3. 11.x core/modules/mysql/tests/src/Kernel/mysql/DbDumpTest.php \Drupal\Tests\mysql\Kernel\mysql\DbDumpTest::setUp()

Overrides DriverSpecificKernelTestBase::setUp

File

core/modules/mysql/tests/src/Kernel/mysql/DbDumpTest.php, line 90

Class

DbDumpTest
Tests for the database dump commands.

Namespace

Drupal\Tests\mysql\Kernel\mysql

Code

protected function setUp() : void {
    parent::setUp();
    // Create some schemas so our export contains tables.
    $this->installSchema('dblog', [
        'watchdog',
    ]);
    $this->installEntitySchema('block_content');
    $this->installEntitySchema('user');
    $this->installEntitySchema('file');
    $this->installEntitySchema('menu_link_content');
    $this->installEntitySchema('path_alias');
    // 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.
    // cspell:disable-next-line
    $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_discovery',
        'cache_entity',
        'file_managed',
        'menu_link_content',
        'menu_link_content_data',
        'menu_link_content_revision',
        'menu_link_content_field_revision',
        'path_alias',
        'path_alias_revision',
        'user__roles',
        'users',
        'users_field_data',
        'watchdog',
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.