You are here

public function DynamicDepthCalculationTest::_testDepthCache in Taxonomy Term Depth 7

1 call to DynamicDepthCalculationTest::_testDepthCache()
DynamicDepthCalculationTest::testCalculateDepth in ./taxonomy_term_depth.test
Creates and ensures that a feed is unique, checks source, and deletes feed.

File

./taxonomy_term_depth.test, line 97

Class

DynamicDepthCalculationTest
Tests the taxonomy vocabulary interface.

Code

public function _testDepthCache() {
  $tid = $this->terms[2]->tid;

  // Get first time for caching
  $depth_stored = taxonomy_term_depth_get_by_tid($tid);
  $cache =& drupal_static('taxonomy_term_depth', array());
  $cache_key = $tid;
  if ($this
    ->assertTrue(isset($cache[$cache_key]), 'Value was cached')) {
    $this
      ->assertEqual($cache[$cache_key], $depth_stored, 'Cached value is correct');
  }
  $fake_value = 500;
  $cache[$cache_key] = $fake_value;
  $this
    ->assertEqual(taxonomy_term_depth_get_by_tid($tid), $fake_value, 'Cached value retrieved correctly');
  $this
    ->assertEqual(taxonomy_term_depth_get_by_tid($tid, TRUE), _taxonomy_term_depth_get_nocache($tid), 'Got correct data with forced cache clear');
}