/** * load and read the configuration of the application * The combination of all configuration files (the given file * and the mainconfig.ini.php) is stored * in a single temporary file. So it calls the jConfigCompiler * class if needed * @param string $configFile the config file name * @return object it contains all configuration options * @see jConfigCompiler */ public static function load($configFile) { $config = array(); $file = jApp::tempPath() . str_replace('/', '~', $configFile); if (BYTECODE_CACHE_EXISTS) { $file .= '.conf.php'; } else { $file .= '.resultini.php'; } self::$fromCache = true; if (!file_exists($file)) { // no cache, let's compile self::$fromCache = false; } else { $t = filemtime($file); $dc = jApp::mainConfigFile(); $lc = jApp::configPath('localconfig.ini.php'); if (file_exists($dc) && filemtime($dc) > $t || filemtime(jApp::configPath($configFile)) > $t || file_exists($lc) && filemtime($lc) > $t) { // one of the config files have been modified: let's compile self::$fromCache = false; } else { // let's read the cache file if (BYTECODE_CACHE_EXISTS) { include $file; $config = (object) $config; } else { $config = jelix_read_ini($file); } // we check all directories to see if it has been modified if ($config->compilation['checkCacheFiletime']) { foreach ($config->_allBasePath as $path) { if (!file_exists($path) || filemtime($path) > $t) { self::$fromCache = false; break; } } } } } if (!self::$fromCache) { require_once JELIX_LIB_CORE_PATH . 'jConfigCompiler.class.php'; return jConfigCompiler::readAndCache($configFile); } else { return $config; } }
public static function load($configFile) { $config = array(); $file = jApp::tempPath(); if (BYTECODE_CACHE_EXISTS) { $file .= str_replace('/', '~', $configFile) . '.conf.php'; } else { $file .= str_replace('/', '~', $configFile) . '.resultini.php'; } $compil = false; if (!file_exists($file)) { $compil = true; } else { $t = filemtime($file); $dc = jApp::configPath('defaultconfig.ini.php'); if (file_exists($dc) && filemtime($dc) > $t || filemtime(jApp::configPath($configFile)) > $t) { $compil = true; } else { if (BYTECODE_CACHE_EXISTS) { include $file; $config = (object) $config; } else { $config = parse_ini_file($file, true); $config = (object) $config; } if ($config->compilation['checkCacheFiletime']) { foreach ($config->_allBasePath as $path) { if (!file_exists($path) || filemtime($path) > $t) { $compil = true; break; } } } } } if ($compil) { require_once JELIX_LIB_CORE_PATH . 'jConfigCompiler.class.php'; return jConfigCompiler::readAndCache($configFile); } else { return $config; } }
protected function handleCustomTestSuite() { $modulesTests = -1; /* $this->options[0] is an array of all options '--xxx'. each values is an array(0=>'optionname', 1=>'value if given') $this->options[1] is a list of parameters given after options it can be array(0=>'test name', 1=>'filename') */ foreach ($this->options[0] as $option) { switch ($option[0]) { case '--entrypoint': $this->entryPoint = $option[1]; break; case '--all-modules': $modulesTests = 0; break; case '--module': $modulesTests = 1; // test is the module name // testFile is the test file inside the module break; case '--testtype': $this->testType = $option[1]; break; } } if (isset($this->options[1][1]) && $modulesTests != 0) { // a specifique test file $this->arguments['testFile'] = $this->options[1][1]; } else { $this->arguments['testFile'] = ''; } $appInstaller = new jInstallerApplication(); $this->epInfo = $appInstaller->getEntryPointInfo($this->entryPoint); // let's load configuration now, and coordinator. it could be needed by tests // (during load of their php files or during execution) jApp::setConfig(jConfigCompiler::readAndCache($this->epInfo->configFile, null, $this->entryPoint)); jApp::setCoord(new jCoordinator('', false)); if ($modulesTests == 0) { // we add all modules in the test list $suite = $this->getAllModulesTestSuites(); if (count($suite)) { $this->arguments['test'] = $suite; unset($this->arguments['testFile']); } else { $this->showMessage("Error: no tests in modules\n"); exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); } } else { if ($modulesTests == 1 && !$this->version36) { $suite = $this->getModuleTestSuite($this->options[1][0]); if (count($suite)) { $this->arguments['test'] = $suite; if (isset($this->options[1][1])) { // a specifique test file $this->arguments['testFile'] = $this->options[1][1]; } else { $this->arguments['testFile'] = ''; } } else { $this->showMessage("Error: no tests in the module\n"); exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); } } else { if ($modulesTests == 1) { if (isset($this->options[1][1])) { // a specifique test file $suite = $this->getModuleTestSuite($this->options[1][0], $this->options[1][1]); } else { $suite = $this->getModuleTestSuite($this->options[1][0]); } if (count($suite)) { $this->arguments['test'] = $suite; } else { $this->showMessage("Error: no tests in the module\n"); exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT); } } } } }
/** * load and read the configuration of the application * The combination of all configuration files (the given file * and the defaultconfig.ini.php) is stored * in a single temporary file. So it calls the jConfigCompiler * class if needed * @param string $configFile the config file name * @return object it contains all configuration options * @see jConfigCompiler */ public static function load($configFile) { $config = array(); $file = jApp::tempPath(); #if WITH_BYTECODE_CACHE == 'auto' if (BYTECODE_CACHE_EXISTS) { $file .= str_replace('/', '~', $configFile) . '.conf.php'; } else { $file .= str_replace('/', '~', $configFile) . '.resultini.php'; } #elseif WITH_BYTECODE_CACHE $file .= str_replace('/', '~', $configFile) . '.conf.php'; #else $file .= str_replace('/', '~', $configFile) . '.resultini.php'; #endif $compil = false; if (!file_exists($file)) { // no cache, let's compile $compil = true; } else { $t = filemtime($file); $dc = jApp::configPath('defaultconfig.ini.php'); if (file_exists($dc) && filemtime($dc) > $t || filemtime(jApp::configPath($configFile)) > $t) { // one of the two config file have been modified: let's compile $compil = true; } else { // let's read the cache file #if WITH_BYTECODE_CACHE == 'auto' if (BYTECODE_CACHE_EXISTS) { include $file; $config = (object) $config; } else { #if ENABLE_PHP_JELIX $config = jelix_read_ini($file); #else $config = parse_ini_file($file, true); $config = (object) $config; #endif } #elseif WITH_BYTECODE_CACHE include $file; $config = (object) $config; #else #if ENABLE_PHP_JELIX $config = jelix_read_ini($file); #else $config = parse_ini_file($file, true); $config = (object) $config; #endif #endif // we check all directories to see if it has been modified if ($config->compilation['checkCacheFiletime']) { foreach ($config->_allBasePath as $path) { if (!file_exists($path) || filemtime($path) > $t) { $compil = true; break; } } } } } if ($compil) { require_once JELIX_LIB_CORE_PATH . 'jConfigCompiler.class.php'; return jConfigCompiler::readAndCache($configFile); } else { return $config; } }