public function PermanentMemcacheBackendTest::testSetGet in Permanent Cache Bin 8
Testing the basic goals of the permanent memcache cache.
Overrides GenericCacheBackendUnitTestBase::testSetGet
File
- modules/
pcb_memcache/ tests/ src/ Kernel/ PermanentMemcacheBackendTest.php, line 62
Class
- PermanentMemcacheBackendTest
- Tests the PermanentMemcacheBackendTest.
Namespace
Drupal\Tests\pcb_memcache\KernelCode
public function testSetGet() {
$backend = $this
->getCacheBackend();
$cid = 'test';
$cache_value = 'This does not matter.';
// Be sure that our cache key is empty.
$this
->assertSame(FALSE, $backend
->get($cid), "Backend does not contain data for the used cache id.");
// Initialize the cache value.
$backend
->set($cid, $cache_value);
$cached = $backend
->get($cid);
$this
->assertEquals($cache_value, $cached->data, 'Backend returned the proper value before the normal deleting process.');
// This is the original cache deleteAll method, so we don't want to delete
// anything at this moment.
$backend
->deleteAll();
$cached = $backend
->get($cid);
$this
->assertFalse(!is_object($cached), 'Backend did not provide result after the normal deleting process.');
$this
->assertEquals($cache_value, $cached->data, 'Backend returned the proper value after the normal deleting process.');
// Now flush the permanent cache!
$backend
->deleteAllPermanent();
$cached = $backend
->get($cid);
$this
->assertFalse(is_object($cached), 'Backend returned result after the permanent cache was deleted.');
}