abstract class Redis_Tests_Path_PathUnitTestCase in Redis 7.3
Bugfixes made over time test class.
Hierarchy
- class \DrupalTestCase
- class \DrupalUnitTestCase
Expanded class hierarchy of Redis_Tests_Path_PathUnitTestCase
1 string reference to 'Redis_Tests_Path_PathUnitTestCase'
- PhpRedisPathUnitTestCase.test in lib/
Redis/ Tests/ Path/ PhpRedisPathUnitTestCase.test
File
- lib/
Redis/ Tests/ Path/ PathUnitTestCase.php, line 6
View source
abstract class Redis_Tests_Path_PathUnitTestCase extends Redis_Tests_AbstractUnitTestCase {
/**
* @var Cache bin identifier
*/
private static $id = 1;
/**
* Get cache backend
*
* @return Redis_Path_HashLookupInterface
*/
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++;
}
$className = Redis_Client::getClass(Redis_Client::REDIS_IMPL_PATH);
$hashLookup = new $className(Redis_Client::getClient(), 'path', Redis_Client::getDefaultPrefix('path'));
return $hashLookup;
}
/**
* Tests basic functionnality
*/
public function testPathLookup() {
$backend = $this
->getBackend();
$source = $backend
->lookupSource('node-1-fr', 'fr');
$this
->assertIdentical(null, $source);
$alias = $backend
->lookupAlias('node/1', 'fr');
$this
->assertIdentical(null, $source);
$backend
->saveAlias('node/1', 'node-1-fr', 'fr');
$source = $backend
->lookupSource('node-1-fr', 'fr');
$source = $backend
->lookupSource('node-1-fr', 'fr');
$this
->assertIdentical('node/1', $source);
$alias = $backend
->lookupAlias('node/1', 'fr');
$this
->assertIdentical('node-1-fr', $alias);
// Delete and ensure it does not exist anymore.
$backend
->deleteAlias('node/1', 'node-1-fr', 'fr');
$source = $backend
->lookupSource('node-1-fr', 'fr');
$this
->assertIdentical(null, $source);
$alias = $backend
->lookupAlias('node/1', 'fr');
$this
->assertIdentical(null, $source);
// Set more than one aliases and ensure order at loading.
$backend
->saveAlias('node/1', 'node-1-fr-1', 'fr');
$backend
->saveAlias('node/1', 'node-1-fr-2', 'fr');
$backend
->saveAlias('node/1', 'node-1-fr-3', 'fr');
$alias = $backend
->lookupAlias('node/1', 'fr');
$this
->assertIdentical('node-1-fr-3', $alias);
// Add another alias to test the delete language feature.
// Also add some other languages aliases.
$backend
->saveAlias('node/1', 'node-1');
$backend
->saveAlias('node/2', 'node-2-en', 'en');
$backend
->saveAlias('node/3', 'node-3-ca', 'ca');
// Ok, delete fr and tests every other are still there.
$backend
->deleteLanguage('fr');
$alias = $backend
->lookupAlias('node/1');
$this
->assertIdentical('node-1', $alias);
$alias = $backend
->lookupAlias('node/2', 'en');
$this
->assertIdentical('node-2-en', $alias);
$alias = $backend
->lookupAlias('node/3', 'ca');
$this
->assertIdentical('node-3-ca', $alias);
// Now create back a few entries in some langage and
// ensure fallback to no language also works.
$backend
->saveAlias('node/4', 'node-4');
$backend
->saveAlias('node/4', 'node-4-es', 'es');
$alias = $backend
->lookupAlias('node/4');
$this
->assertIdentical('node-4', $alias);
$alias = $backend
->lookupAlias('node/4', 'es');
$this
->assertIdentical('node-4-es', $alias);
$alias = $backend
->lookupAlias('node/4', 'fr');
$this
->assertIdentical('node-4', $alias);
}
/**
* Tests https://www.drupal.org/node/2728831
*/
public function testSomeEdgeCaseFalseNegative() {
$backend = $this
->getBackend();
$backend
->deleteLanguage('fr');
$backend
->deleteLanguage('und');
$backend
->saveAlias('node/123', 'node-123');
// Language lookup should return the language neutral value if no value
$source = $backend
->lookupSource('node-123', 'fr');
$this
->assertIdentical($source, 'node/123');
$source = $backend
->lookupAlias('node/123', 'fr');
$this
->assertIdentical($source, 'node-123');
// Now, let's consider we have an item we don't know if it exists or
// not, per definition we should not return a strict FALSE but a NULL
// value instead to tell "we don't know anything about this". In a
// very specific use-case, if the language neutral value is a strict
// "not exists" value, it should still return NULL instead of FALSE
// if another language was asked for.
// Store "value null" for the language neutral entry
$backend
->saveAlias('node/456', Redis_Path_HashLookupInterface::VALUE_NULL);
$source = $backend
->lookupAlias('node/456');
$this
->assertIdentical(false, $source);
$source = $backend
->lookupAlias('node/456', 'fr');
$this
->assertIdentical(null, $source);
}
/**
* Tests that lookup is case insensitive
*/
public function testCaseInsensitivePathLookup() {
$backend = $this
->getBackend();
$backend
->saveAlias('node/1', 'Node-1-FR', 'fr');
$source = $backend
->lookupSource('NODE-1-fr', 'fr');
$this
->assertIdentical('node/1', $source);
$source = $backend
->lookupSource('node-1-FR', 'fr');
$this
->assertIdentical('node/1', $source);
$alias = $backend
->lookupAlias('node/1', 'fr');
$this
->assertIdentical('node-1-fr', strtolower($alias));
// Delete and ensure it does not exist anymore.
$backend
->deleteAlias('node/1', 'node-1-FR', 'fr');
$source = $backend
->lookupSource('Node-1-FR', 'fr');
$this
->assertIdentical(null, $source);
$alias = $backend
->lookupAlias('node/1', 'fr');
$this
->assertIdentical(null, $source);
}
}
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_Path_PathUnitTestCase:: |
private static | property | ||
Redis_Tests_Path_PathUnitTestCase:: |
final protected | function | Get cache backend | |
Redis_Tests_Path_PathUnitTestCase:: |
public | function | Tests that lookup is case insensitive | |
Redis_Tests_Path_PathUnitTestCase:: |
public | function | Tests basic functionnality | |
Redis_Tests_Path_PathUnitTestCase:: |
public | function | Tests https://www.drupal.org/node/2728831 |