function SharedDatabaseStateTest::testNothingWasRestored
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/SharedDatabaseStateTest.php \Drupal\KernelTests\SharedDatabaseStateTest::testNothingWasRestored()
Tests that nothing the previous test method did was undone.
Attributes
#[Depends('testStateIsWritable')]
File
-
core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateTest.php, line 125
Class
- SharedDatabaseStateTest
- Tests the shared database state of Drupal\KernelTests\KernelTestBase.
Namespace
Drupal\KernelTestsCode
public function testNothingWasRestored() : void {
// The inserted row is still there and the updated one is still updated.
$this->assertSame([
[
'id' => '1',
'name' => 'changed',
],
[
'id' => '2',
'name' => 'second',
],
], $this->readProbes());
// So is the entity the previous test method created.
$this->assertCount(1, User::loadMultiple());
// The table that the previous test method created is gone, because
// ::resetEnvironment() removed it. Rows survive, schema does not.
$this->assertFalse($this->container
->get('database')
->schema()
->tableExists(self::CREATED_TABLE));
// The serial ID kept advancing, because nothing rewound it.
$this->insertProbe('third');
$this->assertSame([
[
'id' => '1',
'name' => 'changed',
],
[
'id' => '2',
'name' => 'second',
],
[
'id' => '3',
'name' => 'third',
],
], $this->readProbes());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.