You are here

public function DbDumpTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Update/DbDumpTest.php \Drupal\system\Tests\Update\DbDumpTest::setUp()

Performs setup tasks before each individual test method is run.

Overrides KernelTestBase::setUp

File

core/modules/system/src/Tests/Update/DbDumpTest.php, line 84
Contains \Drupal\system\Tests\Update\DbDumpTest.

Class

DbDumpTest
Tests for the database dump commands.

Namespace

Drupal\system\Tests\Update

Code

public function setUp() {
  parent::setUp();

  // Determine what database backend is running, and set the skip flag.
  $this->skipTests = Database::getConnection()
    ->databaseType() !== 'mysql';

  // Create some schemas so our export contains tables.
  $this
    ->installSchema('system', [
    'key_value_expire',
    'semaphore',
    'sessions',
    'url_alias',
  ]);
  $this
    ->installSchema('dblog', [
    'watchdog',
  ]);
  $this
    ->installEntitySchema('block_content');
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('file');
  $this
    ->installEntitySchema('menu_link_content');
  $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 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_discovery',
    'cache_entity',
    'file_managed',
    'key_value_expire',
    'menu_link_content',
    'menu_link_content_data',
    'semaphore',
    'sequences',
    'sessions',
    'url_alias',
    'user__roles',
    'users',
    'users_field_data',
    'watchdog',
  ];
}