function KernelTestBase::checkNoSharedTableWasDropped
Same name and namespace in other branches
- 11.x 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
2 calls to KernelTestBase::checkNoSharedTableWasDropped()
- KernelTestBase::checkSharedDatabaseState in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - Checks the shared database state after a test method has run.
- SharedDatabaseStateViolationTest::testDroppedTableIsReported in core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateViolationTest.php - Tests that dropping a table of the initial state is reported.
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 1254
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
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.