function TaxonomyTermCacheUsageTestCase::testTaxonomyGetTermByNameCacheUsage

Test taxonomy_get_term_by_name() cache usage.

File

modules/taxonomy/taxonomy.test, line 2240

Class

TaxonomyTermCacheUsageTestCase
Tests for taxonomy terms cache usage.

Code

function testTaxonomyGetTermByNameCacheUsage() {
    // Create vocabulary and term.
    $new_vocabulary = $this->createVocabulary();
    $new_term = new stdClass();
    $new_term->name = 'MixedCaseTerm';
    $new_term->vid = $new_vocabulary->vid;
    taxonomy_term_save($new_term);
    // Try to load term with mixed case letters from the cache.
    $taxonomy_controller = new TestTaxonomyTermController('taxonomy_term');
    // First load to warm the cache.
    $terms = $taxonomy_controller->load(array(), array(
        'name' => $new_term->name,
    ));
    $this->assertTrue(isset($terms[$new_term->tid]), 'Term loaded using exact name and vocabulary machine name.');
    // Second load should load the $new_term from the cache.
    $terms = $taxonomy_controller->loadFromCache(array(), array(
        'name' => $new_term->name,
    ));
    $this->assertTrue(isset($terms[$new_term->tid]), 'Term loaded using the cache.');
}

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