function StateTest::testDeleteAfterGet

Tests both get() & delete() method.

Here testing the key and value after deleting the key's value.

@covers ::get @covers ::delete

Ensure that deleting clears some static cache.

File

core/tests/Drupal/Tests/Core/State/StateTest.php, line 328

Class

StateTest
@coversDefaultClass \Drupal\Core\State\State @group State

Namespace

Drupal\Tests\Core\State

Code

public function testDeleteAfterGet() : void {
    $values = [
        'key' => 'value',
    ];
    $this->keyValueStorage
        ->expects($this->once())
        ->method('setMultiple')
        ->with($values);
    $this->state
        ->setMultiple($values);
    $this->assertEquals('value', $this->state
        ->get('key'));
    $this->state
        ->delete('key');
    $this->assertEquals(NULL, $this->state
        ->get('key'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.