function SharedDatabaseStateViolationTest::testDroppedTableIsReported
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/SharedDatabaseStateViolationTest.php \Drupal\KernelTests\SharedDatabaseStateViolationTest::testDroppedTableIsReported()
Tests that dropping a table of the initial state is reported.
File
-
core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateViolationTest.php, line 68
Class
- SharedDatabaseStateViolationTest
- Tests how "KernelTestBase" reports shared database state violations.
Namespace
Drupal\KernelTestsCode
public function testDroppedTableIsReported() : void {
$connection = $this->container
->get('database');
$connection->schema()
->dropTable(self::PROBE_TABLE);
$caught = NULL;
try {
$this->checkNoSharedTableWasDropped();
} catch (\RuntimeException $e) {
$caught = $e;
}
$this->assertNotNull($caught, 'Dropping a table of the initial state is reported.');
$this->assertStringContainsString(self::PROBE_TABLE, $caught->getMessage());
$this->assertStringContainsString('belongs to the shared environment', $caught->getMessage());
// Putting the table back is enough to let the check in ::tearDown() pass.
$connection->schema()
->createTable(self::PROBE_TABLE, self::PROBE_SCHEMA);
$connection->insert(self::PROBE_TABLE)
->fields([
'id' => 1,
])
->execute();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.