function 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\DataCollectorCode
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());
}