function StateTest::testResetCache

Tests both resetCache(), get() and getMultiple() method.

Here testing the get() and getMultiple() functions both before after calling resetCache() function.

@covers ::resetCache
@covers ::get
@covers ::getMultiple

@depends testSet

Parameters

\Drupal\Core\State\State $state: The tested state.

File

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

Class

StateTest
@coversDefaultClass \Drupal\Core\State\State[[api-linebreak]] @group State

Namespace

Drupal\Tests\Core\State

Code

public function testResetCache(State $state) : void {
  $this->assertEquals('value', $state->get('key'));
  $this->state
    ->resetCache();
  $this->assertEquals('value', $state->get('key'));
  $this->assertEquals([
    'key' => 'value',
  ], $state->getMultiple([
    'key',
  ]));
  $this->state
    ->resetCache();
  $this->assertEquals([
    'key' => 'value',
  ], $state->getMultiple([
    'key',
  ]));
}

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