foreach ($basicCaches as $cacheSvc => $cacheGrp) {
$definitionParams = [
'name' => $cacheGrp . (in_array($cacheGrp, $verSuffixCaches) ? $verSuffix : ''),
- // FIXME: Uncommenting below causes test failure
- // 'service' => $cacheSvc,
+ 'service' => $cacheSvc,
'type' => ['*memory*', 'SqlGroup', 'ArrayCache'],
];
// For Caches that we don't really care about the ttl for and/or maybe accessed
* as it's being deleted.
*/
public static function onClearMetadata(): void {
- \Civi::resources()->resetCacheCode();
+ // This seems to cause problems during unit test setup
+ if (CIVICRM_UF === 'UnitTests') {
+ return;
+ }
+ if (\Civi\Core\Container::singleton()->has('resources')) {
+ \Civi::resources()->resetCacheCode();
+ }
}
}
'civi.api.prepare' => ['myCiviApiPrepare', 1234],
'hook_civicrm_alterContent' => ['myAlterContentObject', -7000],
'&hook_civicrm_alterContent' => ['myAlterContentParams', -8000],
+ 'civi.cache.metadata.clear' => 'myCacheClear',
];
}
$content .= ' ' . __FUNCTION__;
}
+ public function myCacheClear(GenericHookEvent $event): void {
+ $this->tracker['civi.cache.metadata.clear'][__FUNCTION__] = TRUE;
+ }
+
public function testPageOutput(): void {
ob_start();
$p = new Main();
$this->assertEquals(['myCiviApiPrepare' => TRUE], $this->tracker['civi.api.prepare']);
}
+ public function testCacheClearEvent(): void {
+ $this->tracker['civi.cache.metadata.clear'] = NULL;
+ \Civi::cache('metadata')->clear();
+ $this->assertEquals(['myCacheClear' => TRUE], $this->tracker['civi.cache.metadata.clear']);
+ }
+
}