function KernelTestBase::invalidateDatabaseState
Records that the shared database state can no longer be trusted.
The record is committed, so it outlives the test method process and every test method that follows reports the same reason.
Parameters
string $reason: Why the state is no longer usable.
4 calls to KernelTestBase::invalidateDatabaseState()
- KernelTestBase::bootKernel in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - Bootstraps a kernel for a test.
- KernelTestBase::checkSharedDatabaseState in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - Checks the shared database state after a test method has run.
- KernelTestBase::tearDownEnvironment in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - Cleans the environment up after a test method and checks the result.
- SharedDatabaseStateViolationTest::testInvalidationRecordsTheReason in core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateViolationTest.php - Tests that invalidating the state records the reason durably.
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 1378
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
protected function invalidateDatabaseState(string $reason) : void {
$connection = $this->container
->get('database');
if (!$connection->schema()
->tableExists(self::STATE_TABLE)) {
$this->createStateTable();
}
$connection->delete(self::STATE_TABLE)
->execute();
$connection->insert(self::STATE_TABLE)
->fields([
'status' => 'invalid',
'message' => $reason,
'tables' => NULL,
])
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.