示例#1
0
 /**
  * Creates a Database object, opens the connection and returns the instance.
  *
  * @param context TestSwarmContext
  * @param $connType int: [optional]
  */
 public static function newFromContext(TestSwarmContext $context, $connType = SWARM_DBCON_DEFAULT)
 {
     $dbConf = $context->getConf()->database;
     $db = new self();
     $db->context = $context;
     $db->host = $dbConf->host;
     $db->username = $dbConf->username;
     $db->password = $dbConf->password;
     $db->dbname = $dbConf->database;
     $db->open($connType);
     return $db;
 }
示例#2
0
文件: init.php 项目: hashar/testswarm
$swarmConfig->storage->cacheDir = str_replace("\$1", $swarmInstallDir, $swarmConfig->storage->cacheDir);
// Caching directory must exist and be writable
if (!is_dir($swarmConfig->storage->cacheDir) || !is_writable($swarmConfig->storage->cacheDir)) {
    echo "<b>TestSwarm Fatal</b>: Caching directory must exist and be writable by the script!\n";
    exit;
}
// Refresh control
// The value in settings file is for changes by the local administrator.
// this one is for internal changes, e.g. to be increased when for example
// ./js/run.js changes significantly.
$refresh_control = 3;
// 2012-05-07
$swarmConfig->client->refresh_control += $refresh_control;
/**@}*/
/**
 * Context
 * @{
 */
$swarmContext = new TestSwarmContext($swarmConfig);
/**@}*/
/**
 * Custom settings
 * @{
 */
if ($swarmContext->getConf()->debug->phpErrorReporting) {
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
}
// Increase the session timeout to two weeks (3600 * 24 * 14)
ini_set('session.gc_maxlifetime', '1209600');
/**@}*/
示例#3
0
 public static function validateRunToken(TestSwarmContext $context, $runToken)
 {
     $conf = $context->getConf();
     if (!$conf->client->requireRunToken) {
         return true;
     }
     $cacheFile = $conf->storage->cacheDir . "/run_token_hash.cache";
     if (!is_readable($cacheFile)) {
         throw new SwarmException("Configuration requires a runToken but none has been configured.");
     }
     $runTokenHash = trim(file_get_contents($cacheFile));
     if ($runTokenHash === sha1($runToken)) {
         return true;
     }
     throw new SwarmException("This TestSwarm requires a run token. Either none was entered or it is invalid.");
 }
示例#4
0
 public static function getMaxAge(TestSwarmContext $context)
 {
     $conf = $context->getConf();
     return time() - ($conf->client->pingTime + $conf->client->pingTimeMargin);
 }