You are here

public function CleanerTestBase::cleanerSaveDummyCache in Cleaner 7

Save dummy cache.

Parameters

string $cid: Cache ID(CID).

Return value

string Cache value which has been set.

1 call to CleanerTestBase::cleanerSaveDummyCache()
CleanerTestCacheClearing::testCacheClearing in tests/cleaner_cache.test
Test clearing caches.

File

tests/cleaner_base.test, line 82
File with a base class for the Cleaner test cases.

Class

CleanerTestBase
Class CleanerTestBase.

Code

public function cleanerSaveDummyCache($cid) {
  $this
    ->assertTrue(is_string($cid));

  // Create the variable with a random string and save it to the cache.
  $dummy_cache = $this
    ->randomString();

  // Check if dummy cache variable has been created and it has a string type.
  $this
    ->assertTrue(is_string($dummy_cache), 'Dummy cache variable has been created');

  // Save cache.
  cache_set($cid, $dummy_cache, 'cache', REQUEST_TIME + 3600);

  // Check if dummy cache variable has been saved to the cache.
  $this
    ->assertNotEqual(cache_get($cid, 'cache'), FALSE, 'Dummy cache variable has been saved to the cache.');
  return $dummy_cache;
}