abstract class Redis_Tests_Cache_FlushUnitTestCase in Redis 7.3
Hierarchy
- class \DrupalTestCase
Expanded class hierarchy of Redis_Tests_Cache_FlushUnitTestCase
2 string references to 'Redis_Tests_Cache_FlushUnitTestCase'
- CompressedPhpRedisFlushUnitTestCase.test in lib/
Redis/ Tests/ Cache/ CompressedPhpRedisFlushUnitTestCase.test - PhpRedisFlushUnitTestCase.test in lib/
Redis/ Tests/ Cache/ PhpRedisFlushUnitTestCase.test
File
- lib/
Redis/ Tests/ Cache/ FlushUnitTestCase.php, line 3
View source
abstract class Redis_Tests_Cache_FlushUnitTestCase extends Redis_Tests_AbstractUnitTestCase {
/**
* @var Cache bin identifier
*/
private static $id = 1;
protected function createCacheInstance($name = null) {
return new Redis_Cache($name);
}
/**
* Get cache backend
*
* @return Redis_Cache
*/
protected final function getBackend($name = null) {
if (null === $name) {
// This is needed to avoid conflict between tests, each test
// seems to use the same Redis namespace and conflicts are
// possible.
$name = 'cache' . self::$id++;
}
$backend = $this
->createCacheInstance($name);
$this
->assert(true, "Redis client is " . ($backend
->isSharded() ? '' : "NOT ") . " sharded");
$this
->assert(true, "Redis client is " . ($backend
->allowTemporaryFlush() ? '' : "NOT ") . " allowed to flush temporary entries");
$this
->assert(true, "Redis client is " . ($backend
->allowPipeline() ? '' : "NOT ") . " allowed to use pipeline");
return $backend;
}
/**
* Tests that with a default cache lifetime temporary non expired
* items are kept even when in temporary flush mode.
*/
public function testFlushIsTemporaryWithLifetime() {
$GLOBALS['conf']['cache_lifetime'] = 112;
$backend = $this
->getBackend();
// Even though we set a flush mode into this bin, Drupal default
// behavior when a cache_lifetime is set is to override the backend
// one in order to keep the core behavior and avoid potential
// nasty bugs.
$this
->assertFalse($backend
->allowTemporaryFlush());
$backend
->set('test7', 42, CACHE_PERMANENT);
$backend
->set('test8', 'foo', CACHE_TEMPORARY);
$backend
->set('test9', 'bar', time() + 1000);
$backend
->clear();
$cache = $backend
->get('test7');
$this
->assertNotEqual(false, $cache);
$this
->assertEqual($cache->data, 42);
$cache = $backend
->get('test8');
$this
->assertNotEqual(false, $cache);
$this
->assertEqual($cache->data, 'foo');
$cache = $backend
->get('test9');
$this
->assertNotEqual(false, $cache);
$this
->assertEqual($cache->data, 'bar');
}
/**
* Tests that with no default cache lifetime all temporary items are
* droppped when in temporary flush mode.
*/
public function testFlushIsTemporaryWithoutLifetime() {
$backend = $this
->getBackend();
$this
->assertTrue($backend
->allowTemporaryFlush());
$backend
->set('test10', 42, CACHE_PERMANENT);
// Ugly concatenation with the mode, but it will be visible in tests
// reports if the entry shows up, thus allowing us to know which real
// test case is run at this time
$backend
->set('test11', 'foo' . $backend
->isSharded(), CACHE_TEMPORARY);
$backend
->set('test12', 'bar' . $backend
->isSharded(), time() + 10);
$backend
->clear();
$cache = $backend
->get('test10');
$this
->assertNotEqual(false, $cache);
$this
->assertEqual($cache->data, 42);
$this
->assertFalse($backend
->get('test11'));
$cache = $backend
->get('test12');
$this
->assertNotEqual(false, $cache);
}
public function testNormalFlushing() {
$backend = $this
->getBackend();
$backendUntouched = $this
->getBackend();
// Set a few entries.
$backend
->set('test13', 'foo');
$backend
->set('test14', 'bar', CACHE_TEMPORARY);
$backend
->set('test15', 'baz', time() + 3);
$backendUntouched
->set('test16', 'dog');
$backendUntouched
->set('test17', 'cat', CACHE_TEMPORARY);
$backendUntouched
->set('test18', 'xor', time() + 5);
// This should not do anything (bugguy command)
$backend
->clear('', true);
$backend
->clear('', false);
$this
->assertNotIdentical(false, $backend
->get('test13'));
$this
->assertNotIdentical(false, $backend
->get('test14'));
$this
->assertNotIdentical(false, $backend
->get('test15'));
$this
->assertNotIdentical(false, $backendUntouched
->get('test16'));
$this
->assertNotIdentical(false, $backendUntouched
->get('test17'));
$this
->assertNotIdentical(false, $backendUntouched
->get('test18'));
// This should clear every one, permanent and volatile
$backend
->clear('*', true);
$this
->assertFalse($backend
->get('test13'));
$this
->assertFalse($backend
->get('test14'));
$this
->assertFalse($backend
->get('test15'));
$this
->assertNotIdentical(false, $backendUntouched
->get('test16'));
$this
->assertNotIdentical(false, $backendUntouched
->get('test17'));
$this
->assertNotIdentical(false, $backendUntouched
->get('test18'));
}
public function testPrefixDeletionWithSeparatorChar() {
$backend = $this
->getBackend();
$backend
->set('testprefix10', 'foo');
$backend
->set('testprefix11', 'foo');
$backend
->set('testprefix:12', 'bar');
$backend
->set('testprefix:13', 'baz');
$backend
->set('testnoprefix14', 'giraffe');
$backend
->set('testnoprefix:15', 'elephant');
$backend
->clear('testprefix:', true);
$this
->assertFalse($backend
->get('testprefix:12'));
$this
->assertFalse($backend
->get('testprefix:13'));
// @todo Temporary fix
// At the moment shard enabled backends will erase all data instead
// of just removing by prefix, so those tests won't pass
if (!$backend
->isSharded()) {
$this
->assertNotIdentical(false, $backend
->get('testprefix10'));
$this
->assertNotIdentical(false, $backend
->get('testprefix11'));
$this
->assertNotIdentical(false, $backend
->get('testnoprefix14'));
$this
->assertNotIdentical(false, $backend
->get('testnoprefix:15'));
}
$backend
->clear('testprefix', true);
$this
->assertFalse($backend
->get('testprefix10'));
$this
->assertFalse($backend
->get('testprefix11'));
// @todo Temporary fix
// At the moment shard enabled backends will erase all data instead
// of just removing by prefix, so those tests won't pass
if (!$backend
->isSharded()) {
$this
->assertNotIdentical(false, $backend
->get('testnoprefix14'));
$this
->assertNotIdentical(false, $backend
->get('testnoprefix:15'));
}
}
public function testOrder() {
$backend = $this
->getBackend();
for ($i = 0; $i < 10; ++$i) {
$id = 'speedtest' . $i;
$backend
->set($id, 'somevalue');
$this
->assertNotIdentical(false, $backend
->get($id));
$backend
->clear('*', true);
// Value created the same second before is dropped
$this
->assertFalse($backend
->get($id));
$backend
->set($id, 'somevalue');
// Value created the same second after is kept
$this
->assertNotIdentical(false, $backend
->get($id));
}
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalTestCase:: |
protected | property | Assertions thrown in that test case. | |
DrupalTestCase:: |
protected | property | The database prefix of this test run. | |
DrupalTestCase:: |
protected | property | The original file directory, before it was changed for testing purposes. | |
DrupalTestCase:: |
public | property | Current results of this test case. | |
DrupalTestCase:: |
protected | property | Flag to indicate whether the test has been set up. | |
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | This class is skipped when looking for the source of an assertion. | |
DrupalTestCase:: |
protected | property | The test run ID. | |
DrupalTestCase:: |
protected | property | Time limit for the test. | |
DrupalTestCase:: |
public | property | Whether to cache the installation part of the setUp() method. | |
DrupalTestCase:: |
public | property | Whether to cache the modules installation part of the setUp() method. | |
DrupalTestCase:: |
protected | property | URL to the verbose output file directory. | |
DrupalTestCase:: |
protected | function | Internal helper: stores the assert. | |
DrupalTestCase:: |
protected | function | Check to see if two values are equal. | |
DrupalTestCase:: |
protected | function | Check to see if a value is false (an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
protected | function | Check to see if two values are identical. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not equal. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not identical. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not false (not an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
public static | function | Delete an assertion record by message ID. | |
DrupalTestCase:: |
protected | function | Fire an error assertion. | 1 |
DrupalTestCase:: |
public | function | Handle errors during test runs. | 1 |
DrupalTestCase:: |
protected | function | Handle exceptions. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always negative. | |
DrupalTestCase:: |
public static | function | Converts a list of possible parameters into a stack of permutations. | |
DrupalTestCase:: |
protected | function | Cycles through backtrace until the first non-assertion method is found. | |
DrupalTestCase:: |
public static | function | Returns the database connection to the site running Simpletest. | |
DrupalTestCase:: |
public static | function | Store an assertion from outside the testing context. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always positive. | |
DrupalTestCase:: |
public static | function | Generates a random string containing letters and numbers. | |
DrupalTestCase:: |
public static | function | Generates a random string of ASCII characters of codes 32 to 126. | |
DrupalTestCase:: |
public | function | Run all tests in this class. | |
DrupalTestCase:: |
protected | function | Logs a verbose message in a text file. | |
DrupalUnitTestCase:: |
function |
Constructor for DrupalUnitTestCase. Overrides DrupalTestCase:: |
||
Redis_Tests_AbstractUnitTestCase:: |
protected static | property | ||
Redis_Tests_AbstractUnitTestCase:: |
private | property | Drupal $conf array backup | |
Redis_Tests_AbstractUnitTestCase:: |
protected static | function | Enable the autoloader | |
Redis_Tests_AbstractUnitTestCase:: |
abstract protected | function | Set up the Redis configuration. | 21 |
Redis_Tests_AbstractUnitTestCase:: |
final private | function | Prepare client manager | |
Redis_Tests_AbstractUnitTestCase:: |
final private | function | Prepare Drupal environmment for testing | |
Redis_Tests_AbstractUnitTestCase:: |
final private | function | Restore client manager | |
Redis_Tests_AbstractUnitTestCase:: |
final private | function | Restore Drupal environment after testing. | |
Redis_Tests_AbstractUnitTestCase:: |
public | function |
Sets up unit test environment. Overrides DrupalUnitTestCase:: |
1 |
Redis_Tests_AbstractUnitTestCase:: |
public | function |
Overrides DrupalUnitTestCase:: |
2 |
Redis_Tests_Cache_FlushUnitTestCase:: |
private static | property | ||
Redis_Tests_Cache_FlushUnitTestCase:: |
protected | function | 2 | |
Redis_Tests_Cache_FlushUnitTestCase:: |
final protected | function | Get cache backend | |
Redis_Tests_Cache_FlushUnitTestCase:: |
public | function | Tests that with a default cache lifetime temporary non expired items are kept even when in temporary flush mode. | |
Redis_Tests_Cache_FlushUnitTestCase:: |
public | function | Tests that with no default cache lifetime all temporary items are droppped when in temporary flush mode. | |
Redis_Tests_Cache_FlushUnitTestCase:: |
public | function | ||
Redis_Tests_Cache_FlushUnitTestCase:: |
public | function | ||
Redis_Tests_Cache_FlushUnitTestCase:: |
public | function |