function StateTest::testDelete
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/State/StateTest.php \Drupal\Tests\Core\State\StateTest::testDelete()
Tests both delete() & deleteMultiple() method.
Those value we are getting from testSetMultiple() function.
@legacy-covers ::delete @legacy-covers ::deleteMultiple
Attributes
#[Depends('testSetMultiple')]
Parameters
\Drupal\Core\State\State $state: The tested state.
File
-
core/
tests/ Drupal/ Tests/ Core/ State/ StateTest.php, line 289
Class
- StateTest
- Tests Drupal\Core\State\State.
Namespace
Drupal\Tests\Core\StateCode
public function testDelete(State $state) : void {
$state->delete('key1');
$this->assertEquals(NULL, $state->get('key1'));
$this->assertEquals([
'key1' => NULL,
], $state->getMultiple([
'key1',
]));
$this->assertEquals('value2', $state->get('key2'));
$this->assertEquals([
'key2' => 'value2',
'key3' => 'value3',
], $state->getMultiple([
'key2',
'key3',
]));
$state->deleteMultiple([
'key2',
'key3',
]);
$this->assertEquals(NULL, $state->get('key2'));
$this->assertEquals(NULL, $state->get('key3'));
$this->assertEquals([
'key2' => NULL,
'key3' => NULL,
], $state->getMultiple([
'key2',
'key3',
]));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.