You are here

public function CacheDataCollectorTest::testCacheCollectorHit in Devel 8

Same name and namespace in other branches
  1. 8.3 webprofiler/tests/src/Unit/DataCollector/CacheDataCollectorTest.php \Drupal\Tests\webprofiler\Unit\DataCollector\CacheDataCollectorTest::testCacheCollectorHit()
  2. 8.2 webprofiler/tests/src/Unit/DataCollector/CacheDataCollectorTest.php \Drupal\Tests\webprofiler\Unit\DataCollector\CacheDataCollectorTest::testCacheCollectorHit()
  3. 4.x webprofiler/tests/src/Unit/DataCollector/CacheDataCollectorTest.php \Drupal\Tests\webprofiler\Unit\DataCollector\CacheDataCollectorTest::testCacheCollectorHit()

Tests the collection of a cache hit.

File

webprofiler/tests/src/Unit/DataCollector/CacheDataCollectorTest.php, line 52

Class

CacheDataCollectorTest
@coversDefaultClass \Drupal\webprofiler\DataCollector\CacheDataCollector

Namespace

Drupal\Tests\webprofiler\Unit\DataCollector

Code

public function testCacheCollectorHit() {
  $cache = new \stdClass();
  $cache->cid = 'cache_id';
  $cache->expire = 1;
  $cache->tags = [
    'tag1',
    'tag2',
  ];
  $this->cacheBackendInterface
    ->expects($this
    ->once())
    ->method('get')
    ->will($this
    ->returnValue($cache));
  $cacheBackendWrapper = new CacheBackendWrapper($this->cacheDataCollector, $this->cacheBackendInterface, 'default');
  $cache2 = $cacheBackendWrapper
    ->get('cache_id');
  $this
    ->assertNotNull($cache2);
  $this
    ->assertEquals(1, $this->cacheDataCollector
    ->getCacheHitsCount());
}