function SharedDatabaseStateTest::testStateIsWritable
Same name and namespace in other branches
- main core/tests/Drupal/KernelTests/SharedDatabaseStateTest.php \Drupal\KernelTests\SharedDatabaseStateTest::testStateIsWritable()
Tests that a test method can change the shared state.
Attributes
#[Depends('testInitialState')]
File
-
core/
tests/ Drupal/ KernelTests/ SharedDatabaseStateTest.php, line 100
Class
- SharedDatabaseStateTest
- Tests the shared database state of Drupal\KernelTests\KernelTestBase.
Namespace
Drupal\KernelTestsCode
public function testStateIsWritable() : void {
$connection = $this->container
->get('database');
$this->insertProbe('second');
$connection->update(self::PROBE_TABLE)
->fields([
'name' => 'changed',
])
->condition('id', 1)
->execute();
User::create([
'name' => 'shared_state_user',
])->save();
$connection->schema()
->createTable(self::CREATED_TABLE, [
'fields' => [
'id' => [
'type' => 'int',
'not null' => TRUE,
],
],
]);
$this->assertSame([
[
'id' => '1',
'name' => 'changed',
],
[
'id' => '2',
'name' => 'second',
],
], $this->readProbes());
$this->assertCount(1, User::loadMultiple());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.