function SharedDatabaseStateTest::setUpEnvironment

Same name and namespace in other branches
  1. main core/tests/Drupal/KernelTests/SharedDatabaseStateTest.php \Drupal\KernelTests\SharedDatabaseStateTest::setUpEnvironment()

Sets up the environment shared by every test method in this class.

Runs once per test class instead of once per test method, and only when the shared environment has to be built. Does nothing by default.

Must be deterministic: what this creates is reused by every test method.

Overrides KernelTestBase::setUpEnvironment

File

core/tests/Drupal/KernelTests/SharedDatabaseStateTest.php, line 46

Class

SharedDatabaseStateTest
Tests the shared database state of Drupal\KernelTests\KernelTestBase.

Namespace

Drupal\KernelTests

Code

protected function setUpEnvironment() : void {
  $this->installEntitySchema('user');
  $this->installConfig([
    'system',
  ]);
  $this->container
    ->get('database')
    ->schema()
    ->createTable(self::PROBE_TABLE, [
    'fields' => [
      'id' => [
        'type' => 'serial',
        'not null' => TRUE,
      ],
      'name' => [
        'type' => 'varchar',
        'length' => 32,
        'not null' => TRUE,
      ],
    ],
    'primary key' => [
      'id',
    ],
  ]);
  $this->insertProbe('initial');
}

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