function _clearCache($accountType) { $oCache = new OA_Cache('Menu', $accountType); $oCache->setFileNameProtection(false); return $oCache->clear(); }
function test_getListOfRegisteredComponentsForHook() { $GLOBALS['_MAX']['CONF']['pluginPaths']['packages'] = '/lib/OX/Plugin/tests/data/plugins/etc/'; $GLOBALS['_MAX']['CONF']['pluginPaths']['admin'] = '/lib/OX/Plugin/tests/data/www/admin/plugins/'; $GLOBALS['_MAX']['CONF']['plugins'] = array('testPluginPackage' => 1); $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] = array('testPlugin' => 1); require_once LIB_PATH . '/Extension/ExtensionCommon.php'; //generate test cache $oExtension = new OX_Extension_Common(); $oExtension->cacheComponentHooks(); $aHooks = OX_Component::getListOfRegisteredComponentsForHook('duringTest'); $this->assertIsA($aHooks, 'array'); $this->assertEqual(count($aHooks), 1); $this->assertEqual($aHooks[0], 'admin:testPlugin:testPlugin'); //remove cache unset($GLOBALS['_MAX']['ComponentHooks']); $oCache = new OA_Cache('Plugins', 'ComponentHooks'); $oCache->setFileNameProtection(false); $oCache->clear(); //should auto regenerate cache $aHooks = OX_Component::getListOfRegisteredComponentsForHook('duringTest'); $this->assertIsA($aHooks, 'array'); $this->assertEqual(count($aHooks), 1); $this->assertEqual($aHooks[0], 'admin:testPlugin:testPlugin'); //cache file should be regenerated $aAllHooks = $oCache->load(); $this->assertEqual($aHooks, $aAllHooks['duringTest']); TestEnv::restoreConfig(); $oCache->clear(); }
function testCacheDir() { $oCache = new OA_Cache('test', 'oxpTestCache'); $oCache->clear(); $result = $oCache->load(true); $this->assertFalse($result); $newCacheDir = dirname(__FILE__) . '/../data/'; $serverName = $_SERVER['HTTP_HOST']; $_SERVER['HTTP_HOST'] = 'myhost'; $oCache = new OA_Cache('test', 'oxpTestCache', null, $newCacheDir); $oCache->setFileNameProtection(false); $result = $oCache->load(true); $this->assertEqual('test', $result); $_SERVER['HTTP_HOST'] = $serverName; }