function DrupalTest::testKeyValue

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testKeyValue()
  2. 8.9.x core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testKeyValue()
  3. 10 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 213

Class

DrupalTest
Tests the Drupal class.

Namespace

Drupal\Tests\Core

Code

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

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