function StateTest::testGetStaticCache

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/State/StateTest.php \Drupal\Tests\Core\State\StateTest::testGetStaticCache()

Tests both get() & getMultiple() method.

Here with the help of testGet() function, testing the key value again.

@legacy-covers ::get @legacy-covers ::getMultiple

Attributes

#[Depends('testGet')]

File

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

Class

StateTest
Tests Drupal\Core\State\State.

Namespace

Drupal\Tests\Core\State

Code

public function testGetStaticCache(State $state) : void {
  $this->keyValueStorage
    ->expects($this->never())
    ->method('getMultiple');
  $this->assertEquals('the-value', $state->get('existing'));
  $this->assertEquals('the-value-2', $state->get('default-value', 'default'));
  $this->assertEquals([
    "existing" => "the-value",
  ], $state->getMultiple([
    'existing',
  ]));
  $this->assertEquals([
    "default-value" => "the-value-2",
    "default" => NULL,
  ], $state->getMultiple([
    'default-value',
    'default',
  ]));
}

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