function CacheClearCase::testIsValidBin

Test DrupalDatabaseCache::isValidBin().

File

modules/simpletest/tests/cache.test, line 346

Class

CacheClearCase
Test cache clearing methods.

Code

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,
            )));
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.