function KernelTestBase::loadSharedDatabaseState
Same name and namespace in other branches
- 11.x core/tests/Drupal/KernelTests/KernelTestBase.php \Drupal\KernelTests\KernelTestBase::loadSharedDatabaseState()
Reads the record describing the shared database state.
Return value
array|null The state record, or NULL when this process has to build the initial state.
File
-
core/
tests/ Drupal/ KernelTests/ KernelTestBase.php, line 1280
Class
- KernelTestBase
- Base class for functional integration tests.
Namespace
Drupal\KernelTestsCode
private function loadSharedDatabaseState() : ?array {
$connection = $this->container
->get('database');
try {
// The read is attempted before checking that the table exists, so that a
// test method finding a state already built spends one query here instead
// of two.
$record = $connection->select(self::STATE_TABLE, 's')
->fields('s', [
'status',
'message',
'tables',
])
->execute()
->fetchAssoc();
} catch (\Exception $e) {
if ($connection->schema()
->tableExists(self::STATE_TABLE)) {
// The table is there, so the query failed for another reason.
throw $e;
}
return NULL;
}
return $record === FALSE ? NULL : $record;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.