ApcCacheClearCase::testFlushAllCaches() tests bins created outside of the APCu store

Created on 26 July 2024, 5 months ago
Updated 9 August 2024, 5 months ago

ApcCacheClearCase::testFlushAllCaches() contains the following code.

// Create cache entries for each flushed cache bin.
$bins = array('cache', 'cache_filter', 'cache_page', 'cache_boostrap', 'cache_path');
$bins = array_merge(module_invoke_all('flush_caches'), $bins);
$value = $this->randomString();

foreach ($bins as $id => $bin) {
  $id = 'test_cid_clear' . $id;
  cache_set($id, $value, $bin);
}

// Remove all caches then make sure that they are cleared.
drupal_flush_all_caches();

foreach ($bins as $id => $bin) {
$id = 'test_cid_clear' . $id;
  $this->assertFalse($this->checkCacheExists($id, $value, $bin), t('All cache entries removed from @bin.', array('@bin' => $bin)));
}

SInce only the cache_apc bin uses the DrupalApcCache class, all those bins are created in the database. To test the DrupalApcCache class, the following lines must be added to the setUp() method.

$bins = array('cache', 'cache_filter', 'cache_page', 'cache_boostrap', 'cache_path');

foreach($bins as $bin) {
  variable_set("cache_class_$bin", 'DrupalApcCache');
}

In the code used by ApcCacheClearCase::testFlushAllCaches(), the line calling module_invoke_all('flush_caches') needs to be removed: The test just needs to verify the cache bins in the APCu store are removed, which in this case are cache, cache_filter, cache_page, cache_boostrap, and cache_path. The other cache bins are stored in the database and are already tested by Drupal core.

🐛 Bug report
Status

Fixed

Version

1.0

Component

Tests

Created by

🇮🇹Italy apaderno Brescia, 🇮🇹

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024