summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJeremy Andrews2013-04-21 13:57:15 (GMT)
committerJeremy Andrews2013-04-21 13:57:15 (GMT)
commit1d4cd8b123044f9760c44fae26575a86d1202f20 (patch)
treeede6cf3d3eb6b6e79b77b3ce5b133fdc93d196c6 /tests
parentfcd303ac665864c39018e7a681d76e8352da1566 (diff)
Issue 1613622 by Jeremy, markpavlitski, tzakrajs: properly hash keys >250 characters
Diffstat (limited to 'tests')
-rw-r--r--tests/memcache.test22
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/memcache.test b/tests/memcache.test
index 6cce365..11f0e4c 100644
--- a/tests/memcache.test
+++ b/tests/memcache.test
@@ -158,13 +158,27 @@ class MemCacheSavingCase extends MemcacheTestCase {
$this->assertTrue(isset($cache->data) && $cache->data == $test_object, t('Object is saved and restored properly.'));
}
+ /**
+ * Test save and restoring a string with a long key.
+ */
+ function testStringLongKey() {
+ $this->checkVariable($this->randomName(100), 'ThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydogThequickbrownfoxjumpsoverthelazydog');
+ }
+
+ /**
+ * Test save and restoring a string using a key with special characters.
+ */
+ function testStringSpecialKey() {
+ $this->checkVariable($this->randomName(100), 'Qwerty!@#$%^&*()_+-=[]\;\',./<>?:"{}|£¢');
+ }
+
/*
* Check or a variable is stored and restored properly.
**/
- function checkVariable($var) {
- cache_set('test_var', $var, 'cache');
- $cache = cache_get('test_var', 'cache');
- $this->assertTrue(isset($cache->data) && $cache->data === $var, t('@type is saved and restored properly.', array('@type' => ucfirst(gettype($var)))));
+ function checkVariable($var, $key = 'test_var') {
+ cache_set($key, $var, 'cache');
+ $cache = cache_get($key, 'cache');
+ $this->assertTrue(isset($cache->data) && $cache->data === $var, t('@type is saved and restored properly!key.', array('@type' => ucfirst(gettype($var)), '!key' => ($key != 'test_var') ? t(' with key @key', array('@key' => $key)) : '')));
}
}