function StateTest::testDeleteMultiple

Tests both deleteMultiple() method.

Here testing the multiple key and value after deleting the key's value in one go.

@covers ::deleteMultiple

File

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

Class

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

Namespace

Drupal\Tests\Core\State

Code

public function testDeleteMultiple() : void {
  $values = [
    'key1' => 'value1',
    'key2' => 'value2',
  ];
  $this->keyValueStorage
    ->expects($this->once())
    ->method('setMultiple')
    ->with($values);
  $this->state
    ->setMultiple($values);
  $this->state
    ->deleteMultiple([
    'key1',
    'key2',
  ]);
  $this->assertEquals([
    'key1' => NULL,
    'key2' => NULL,
  ], $this->state
    ->getMultiple([
    'key1',
    'key2',
  ]));
}

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