function KernelTestBase::checkNoSharedTableWasDropped

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

Fails when a test method dropped a table of the shared environment.

See also

\Drupal\TestTools\Attribute\ShareEnvironment

File

core/tests/Drupal/KernelTests/KernelTestBase.php, line 1293

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

protected function checkNoSharedTableWasDropped() : void {
  $dropped_tables = array_diff($this->environmentTables ?? [], $this->getSharedStateTables());
  if ($dropped_tables !== []) {
    throw new \RuntimeException(sprintf('%s dropped %s, which belongs to the shared environment of the test class. A test method may create tables, and may drop only the tables it created itself.', static::class, implode(', ', $dropped_tables)));
  }
}

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