function KernelTestBase::checkNoTableWasLeftBehind

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

Fails when a test method left a table behind.

See also

\Drupal\TestTools\Attribute\ShareEnvironment

File

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

Class

KernelTestBase
Base class for functional integration tests.

Namespace

Drupal\KernelTests

Code

protected function checkNoTableWasLeftBehind() : void {
  $added_tables = array_diff($this->getSharedStateTables(), $this->environmentTables ?? [], static::INFRASTRUCTURE_TABLES);
  if ($added_tables !== []) {
    throw new \RuntimeException(sprintf('%s left %s behind. A test method that adds to the database schema must remove what it added, in ::resetEnvironment().', static::class, implode(', ', $added_tables)));
  }
}

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