public function testSilentUpgradeSessionVars() { require_once 'modules/UpgradeWizard/uw_utils.php'; $varsCacheFileName = sugar_cached("/silentUpgrader/silentUpgradeCache.php"); $loaded = loadSilentUpgradeVars(); $this->assertTrue($loaded, "Could not load the silent upgrade vars"); global $silent_upgrade_vars_loaded; $this->assertTrue(!empty($silent_upgrade_vars_loaded), "\$silent_upgrade_vars_loaded array should not be empty"); $set = setSilentUpgradeVar('SDizzle', 'BSnizzle'); $this->assertTrue($set, "Could not set a silent upgrade var"); $get = getSilentUpgradeVar('SDizzle'); $this->assertEquals('BSnizzle', $get, "Unexpected value when getting silent upgrade var before resetting"); $write = writeSilentUpgradeVars(); $this->assertTrue($write, "Could not write the silent upgrade vars to the cache file. Function returned false"); $this->assertFileExists($varsCacheFileName, "Cache file doesn't exist after call to writeSilentUpgradeVars()"); $output = shell_exec("php {$this->externalTestFileName}"); $this->assertEquals('BSnizzle', $output, "Running custom script didn't successfully retrieve the value"); $remove = removeSilentUpgradeVarsCache(); $this->assertTrue(empty($silent_upgrade_vars_loaded), "Silent upgrade vars variable should have been unset in removeSilentUpgradeVarsCache() call"); $this->assertFileNotExists($varsCacheFileName, "Cache file exists after call to removeSilentUpgradeVarsCache()"); $get = getSilentUpgradeVar('SDizzle'); $this->assertNotEquals('BSnizzle', $get, "Unexpected value when getting silent upgrade var after resetting"); }
function getSilentUpgradeVar($var) { if (!loadSilentUpgradeVars()) { return false; } global $silent_upgrade_vars_loaded; if (!isset($silent_upgrade_vars_loaded['vars'][$var])) { return null; } else { return $silent_upgrade_vars_loaded['vars'][$var]; } }