update to drupal 7.23
This commit is contained in:
@@ -148,7 +148,7 @@ class CacheSavingCase extends CacheTestCase {
|
||||
|
||||
cache_set('test_object', $test_object, 'cache');
|
||||
$cache = cache_get('test_object', 'cache');
|
||||
$this->assertTrue(isset($cache->data) && $cache->data == $test_object, t('Object is saved and restored properly.'));
|
||||
$this->assertTrue(isset($cache->data) && $cache->data == $test_object, 'Object is saved and restored properly.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ class CacheSavingCase extends CacheTestCase {
|
||||
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)))));
|
||||
$this->assertTrue(isset($cache->data) && $cache->data === $var, format_string('@type is saved and restored properly.', array('@type' => ucfirst(gettype($var)))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ class CacheSavingCase extends CacheTestCase {
|
||||
*/
|
||||
function testNoEmptyCids() {
|
||||
$this->drupalGet('user/register');
|
||||
$this->assertFalse(cache_get(''), t('No cache entry is written with an empty cid.'));
|
||||
$this->assertFalse(cache_get(''), 'No cache entry is written with an empty cid.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,14 +195,14 @@ class CacheGetMultipleUnitTest extends CacheTestCase {
|
||||
$item2 = $this->randomName(10);
|
||||
cache_set('item1', $item1, $this->default_bin);
|
||||
cache_set('item2', $item2, $this->default_bin);
|
||||
$this->assertTrue($this->checkCacheExists('item1', $item1), t('Item 1 is cached.'));
|
||||
$this->assertTrue($this->checkCacheExists('item2', $item2), t('Item 2 is cached.'));
|
||||
$this->assertTrue($this->checkCacheExists('item1', $item1), 'Item 1 is cached.');
|
||||
$this->assertTrue($this->checkCacheExists('item2', $item2), 'Item 2 is cached.');
|
||||
|
||||
// Fetch both records from the database with cache_get_multiple().
|
||||
$item_ids = array('item1', 'item2');
|
||||
$items = cache_get_multiple($item_ids, $this->default_bin);
|
||||
$this->assertEqual($items['item1']->data, $item1, t('Item was returned from cache successfully.'));
|
||||
$this->assertEqual($items['item2']->data, $item2, t('Item was returned from cache successfully.'));
|
||||
$this->assertEqual($items['item1']->data, $item1, 'Item was returned from cache successfully.');
|
||||
$this->assertEqual($items['item2']->data, $item2, 'Item was returned from cache successfully.');
|
||||
|
||||
// Remove one item from the cache.
|
||||
cache_clear_all('item2', $this->default_bin);
|
||||
@@ -210,9 +210,9 @@ class CacheGetMultipleUnitTest extends CacheTestCase {
|
||||
// Confirm that only one item is returned by cache_get_multiple().
|
||||
$item_ids = array('item1', 'item2');
|
||||
$items = cache_get_multiple($item_ids, $this->default_bin);
|
||||
$this->assertEqual($items['item1']->data, $item1, t('Item was returned from cache successfully.'));
|
||||
$this->assertFalse(isset($items['item2']), t('Item was not returned from the cache.'));
|
||||
$this->assertTrue(count($items) == 1, t('Only valid cache entries returned.'));
|
||||
$this->assertEqual($items['item1']->data, $item1, 'Item was returned from cache successfully.');
|
||||
$this->assertFalse(isset($items['item2']), 'Item was not returned from the cache.');
|
||||
$this->assertTrue(count($items) == 1, 'Only valid cache entries returned.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,11 +250,11 @@ class CacheClearCase extends CacheTestCase {
|
||||
cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
|
||||
$this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
&& $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two caches were created for checking cid "*" with wildcard false.'));
|
||||
'Two caches were created for checking cid "*" with wildcard false.');
|
||||
cache_clear_all('*', $this->default_bin);
|
||||
$this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
&& $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two caches still exists after clearing cid "*" with wildcard false.'));
|
||||
'Two caches still exists after clearing cid "*" with wildcard false.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -265,21 +265,21 @@ class CacheClearCase extends CacheTestCase {
|
||||
cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
|
||||
$this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
&& $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two caches were created for checking cid "*" with wildcard true.'));
|
||||
'Two caches were created for checking cid "*" with wildcard true.');
|
||||
cache_clear_all('*', $this->default_bin, TRUE);
|
||||
$this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
|| $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two caches removed after clearing cid "*" with wildcard true.'));
|
||||
'Two caches removed after clearing cid "*" with wildcard true.');
|
||||
|
||||
cache_set('test_cid_clear1', $this->default_value, $this->default_bin);
|
||||
cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
|
||||
$this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
&& $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two caches were created for checking cid substring with wildcard true.'));
|
||||
'Two caches were created for checking cid substring with wildcard true.');
|
||||
cache_clear_all('test_', $this->default_bin, TRUE);
|
||||
$this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
|| $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two caches removed after clearing cid substring with wildcard true.'));
|
||||
'Two caches removed after clearing cid substring with wildcard true.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,16 +293,16 @@ class CacheClearCase extends CacheTestCase {
|
||||
$this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
&& $this->checkCacheExists('test_cid_clear2', $this->default_value)
|
||||
&& $this->checkCacheExists('test_cid_clear3', $this->default_value),
|
||||
t('Three cache entries were created.'));
|
||||
'Three cache entries were created.');
|
||||
|
||||
// Clear two entries using an array.
|
||||
cache_clear_all(array('test_cid_clear1', 'test_cid_clear2'), $this->default_bin);
|
||||
$this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
|| $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two cache entries removed after clearing with an array.'));
|
||||
'Two cache entries removed after clearing with an array.');
|
||||
|
||||
$this->assertTrue($this->checkCacheExists('test_cid_clear3', $this->default_value),
|
||||
t('Entry was not cleared from the cache'));
|
||||
'Entry was not cleared from the cache');
|
||||
|
||||
// Set the cache clear threshold to 2 to confirm that the full bin is cleared
|
||||
// when the threshold is exceeded.
|
||||
@@ -311,12 +311,12 @@ class CacheClearCase extends CacheTestCase {
|
||||
cache_set('test_cid_clear2', $this->default_value, $this->default_bin);
|
||||
$this->assertTrue($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
&& $this->checkCacheExists('test_cid_clear2', $this->default_value),
|
||||
t('Two cache entries were created.'));
|
||||
'Two cache entries were created.');
|
||||
cache_clear_all(array('test_cid_clear1', 'test_cid_clear2', 'test_cid_clear3'), $this->default_bin);
|
||||
$this->assertFalse($this->checkCacheExists('test_cid_clear1', $this->default_value)
|
||||
|| $this->checkCacheExists('test_cid_clear2', $this->default_value)
|
||||
|| $this->checkCacheExists('test_cid_clear3', $this->default_value),
|
||||
t('All cache entries removed when the array exceeded the cache clear threshold.'));
|
||||
'All cache entries removed when the array exceeded the cache clear threshold.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,7 +336,31 @@ class CacheClearCase extends CacheTestCase {
|
||||
|
||||
foreach ($bins as $id => $bin) {
|
||||
$id = 'test_cid_clear' . $id;
|
||||
$this->assertFalse($this->checkCacheExists($id, $this->default_value, $bin), t('All cache entries removed from @bin.', array('@bin' => $bin)));
|
||||
$this->assertFalse($this->checkCacheExists($id, $this->default_value, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test DrupalDatabaseCache::isValidBin().
|
||||
*/
|
||||
function testIsValidBin() {
|
||||
// Retrieve existing cache bins.
|
||||
$valid_bins = array('cache', 'cache_filter', 'cache_page', 'cache_boostrap', 'cache_path');
|
||||
$valid_bins = array_merge(module_invoke_all('flush_caches'), $valid_bins);
|
||||
foreach ($valid_bins as $id => $bin) {
|
||||
$cache = _cache_get_object($bin);
|
||||
if ($cache instanceof DrupalDatabaseCache) {
|
||||
$this->assertTrue($cache->isValidBin(), format_string('Cache bin @bin is valid.', array('@bin' => $bin)));
|
||||
}
|
||||
}
|
||||
|
||||
// Check for non-cache tables and invalid bins.
|
||||
$invalid_bins = array('block', 'filter', 'missing_table', $this->randomName());
|
||||
foreach ($invalid_bins as $id => $bin) {
|
||||
$cache = _cache_get_object($bin);
|
||||
if ($cache instanceof DrupalDatabaseCache) {
|
||||
$this->assertFalse($cache->isValidBin(), format_string('Cache bin @bin is not valid.', array('@bin' => $bin)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,14 +424,14 @@ class CacheIsEmptyCase extends CacheTestCase {
|
||||
function testIsEmpty() {
|
||||
// Clear the cache bin.
|
||||
cache_clear_all('*', $this->default_bin);
|
||||
$this->assertTrue(cache_is_empty($this->default_bin), t('The cache bin is empty'));
|
||||
$this->assertTrue(cache_is_empty($this->default_bin), 'The cache bin is empty');
|
||||
// Add some data to the cache bin.
|
||||
cache_set($this->default_cid, $this->default_value, $this->default_bin);
|
||||
$this->assertCacheExists(t('Cache was set.'), $this->default_value, $this->default_cid);
|
||||
$this->assertFalse(cache_is_empty($this->default_bin), t('The cache bin is not empty'));
|
||||
$this->assertFalse(cache_is_empty($this->default_bin), 'The cache bin is not empty');
|
||||
// Remove the cached data.
|
||||
cache_clear_all($this->default_cid, $this->default_bin);
|
||||
$this->assertCacheRemoved(t('Cache was removed.'), $this->default_cid);
|
||||
$this->assertTrue(cache_is_empty($this->default_bin), t('The cache bin is empty'));
|
||||
$this->assertTrue(cache_is_empty($this->default_bin), 'The cache bin is empty');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user