function getCachedComponentHooks() { require_once MAX_PATH . '/lib/OA/Cache.php'; $oCache = new OA_Cache('Plugins', 'ComponentHooks'); $oCache->setFileNameProtection(false); return $oCache->load(true); }
function test_cachePreferenceOptions() { $oExtension = new OX_Extension_Common(); $GLOBALS['_MAX']['CONF']['pluginPaths']['packages'] = '/lib/OX/Extension/tests/data/'; $GLOBALS['_MAX']['CONF']['pluginGroupComponents'] = array('testPlugin' => 1); $this->_backupCacheFile('PrefOptions_Plugins'); $oExtension->cachePreferenceOptions(); $oCache = new OA_Cache('Plugins', 'PrefOptions'); $oCache->setFileNameProtection(false); $aPrefOptions = $oCache->load(true); $this->assertIsA($aPrefOptions, 'array'); $this->assertEqual(count($aPrefOptions), 1); $this->assertTrue(isset($aPrefOptions['testPlugin'])); $this->assertTrue(isset($aPrefOptions['testPlugin']['value'])); $this->assertTrue(isset($aPrefOptions['testPlugin']['name'])); $this->assertTrue(isset($aPrefOptions['testPlugin']['perm'])); $this->assertEqual($aPrefOptions['testPlugin']['name'], 'testPlugin'); $this->assertEqual($aPrefOptions['testPlugin']['text'], 'Option Text'); $this->assertEqual($aPrefOptions['testPlugin']['value'], 'account-preferences-plugin.php?group=testPlugin'); $this->assertEqual(count($aPrefOptions['testPlugin']['perm']), 4); $this->_restoreCacheFile('PrefOptions_Plugins'); TestEnv::restoreConfig(); }
function getComponentsHookCache() { if (!isset($GLOBALS['_MAX']['ComponentHooks'])) { $oCache = new OA_Cache('Plugins', 'ComponentHooks'); $oCache->setFileNameProtection(false); $GLOBALS['_MAX']['ComponentHooks'] = $oCache->load(true); if ($GLOBALS['_MAX']['ComponentHooks'] === false) { require_once LIB_PATH . '/Plugin/PluginManager.php'; $oPluginManager = new OX_PluginManager(); $GLOBALS['_MAX']['ComponentHooks'] = $oPluginManager->getComponentHooks(); $oCache->save($GLOBALS['_MAX']['ComponentHooks']); } } return $GLOBALS['_MAX']['ComponentHooks']; }
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 _clearCache($accountType) { $oCache = new OA_Cache('Menu', $accountType); $oCache->setFileNameProtection(false); return $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; }
function _mergePluginOptions(&$aSections) { $oCache = new OA_Cache('Plugins', 'PrefOptions'); $oCache->setFileNameProtection(false); $aPrefOptions = $oCache->load(true); if (!empty($aPrefOptions)) { $aSections = array_merge($aSections, $aPrefOptions); } }