function CacheCollectorTest::testSetAndGet

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testSetAndGet()
  2. 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testSetAndGet()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php \Drupal\Tests\Core\Cache\CacheCollectorTest::testSetAndGet()

Tests setting and getting values when the cache is empty.

File

core/tests/Drupal/Tests/Core/Cache/CacheCollectorTest.php, line 80

Class

CacheCollectorTest
@coversDefaultClass \Drupal\Core\Cache\CacheCollector @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public function testSetAndGet() : void {
    $key = $this->randomMachineName();
    $value = $this->randomMachineName();
    $this->assertNull($this->collector
        ->get($key));
    $this->collector
        ->set($key, $value);
    $this->assertTrue($this->collector
        ->has($key));
    $this->assertEquals($value, $this->collector
        ->get($key));
}

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