You are here

public function DrupalTest::testKeyValue in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testKeyValue()

Tests the keyValue() method.

@covers ::keyValue

File

core/tests/Drupal/Tests/Core/DrupalTest.php, line 211

Class

DrupalTest
Tests the Drupal class.

Namespace

Drupal\Tests\Core

Code

public function testKeyValue() {
  $keyvalue = $this
    ->getMockBuilder('Drupal\\Core\\KeyValueStore\\KeyValueFactory')
    ->disableOriginalConstructor()
    ->getMock();
  $keyvalue
    ->expects($this
    ->once())
    ->method('get')
    ->with('test_collection')
    ->will($this
    ->returnValue(TRUE));
  $this
    ->setMockContainerService('keyvalue', $keyvalue);
  $this
    ->assertNotNull(\Drupal::keyValue('test_collection'));
}