You are here

public function DrupalTest::testKeyValue in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/DrupalTest.php \Drupal\Tests\Core\DrupalTest::testKeyValue()
  2. 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 224

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'));
}