예제 #1
0
파일: Utils.php 프로젝트: kanbang/Colt
 public static function SetCommonParams($paramSet, $db)
 {
     $vm = new SqliteVM($db);
     try {
         $arrayParam = array();
         $vm->Execute("Select ParamValue from Params WHERE ParamSet={$paramSet} AND ParamName=\"OPERATION\"");
         $arrayParam["OPERATION"] = $vm->GetString("ParamValue");
         $vm->Execute("Select ParamValue from CommonParams WHERE ParamName=\"VERSION\"");
         $arrayParam["VERSION"] = $vm->GetString("ParamValue");
         $vm->Execute("Select ParamValue from CommonParams WHERE ParamName=\"CREDENTIALS\"");
         $arrayParam["CREDENTIALS"] = $vm->GetString("ParamValue");
         $vm->Execute("Select ParamValue from CommonParams WHERE ParamName=\"LOCALE\"");
         $arrayParam["LOCALE"] = $vm->GetString("ParamValue");
         unset($vm);
         return $arrayParam;
     } catch (MgException $e) {
         print $e->GetExceptionMessage("en");
     } catch (SqliteException $s) {
         try {
             unset($vm);
             $vm = new SqliteVM($db, true);
             $vm->Execute("Select ParamValue from Params WHERE ParamName=\"VERSION\"");
             $arrayParam["VERSION"] = $vm->GetString("ParamValue");
             $vm->Execute("Select ParamValue from Params WHERE ParamName=\"CREDENTIALS\"");
             $arrayParam["CREDENTIALS"] = $vm->GetString("ParamValue");
             $vm->Execute("Select ParamValue from Params WHERE ParamName=\"LOCALE\"");
             $arrayParam["LOCALE"] = $vm->GetString("ParamValue");
             return $arrayParam;
         } catch (SqliteException $sq) {
             print $sq->GetExceptionMessage("eng");
         }
     }
 }
예제 #2
0
 public function PrintTestCases($testSuite, $dumpFilePath, $testType)
 {
     try {
         self::PrintTestTableHeader($testSuite, "Test Case", "Description", "Prerequisite");
         $dbPath = Utils::GetDbPath($dumpFilePath);
         $dbName = Utils::GetPath($dbPath);
         if (file_exists($dbName)) {
             $db = new SqliteDB();
             $db->Open($dbName);
             $vm = new SqliteVM($db, true);
             $status = $vm->Execute("Select * from TestCase WHERE TestType=\"{$testType}\" Order by ExecuteSequence;");
             while ($status == SQLITE_ROW) {
                 $testName = $vm->GetString("TestName");
                 $description = $vm->GetString("Description");
                 $prerequisite = $vm->GetString("Prerequisite");
                 print "<tr>\n";
                 print "<td><input type=\"radio\" name=\"testName\" value=\"{$testName}\"></td>\n";
                 printf("<td>%s</td>\n<td>%s</td><td>%s</td>\n", $testName, $description, $prerequisite);
                 print "<td><input type=\"hidden\" name=\"{$testName}:dbPath\" value=\"{$dbPath}\"></td>\n";
                 print "</tr>\n";
                 $status = $vm->NextRow();
             }
             unset($vm);
             unset($db);
         }
     } catch (SqliteException $s) {
         print $s->GetExceptionMessage();
     }
     self::printTableEnd();
 }
예제 #3
0
파일: RunTests.php 프로젝트: kanbang/Colt
function ExecuteTest($requestType, $dumpFileName, &$testsRun, $file, $ent)
{
    try {
        $exitStatus = 0;
        //Create database objects
        $dbPath = Utils::GetDbPath($dumpFileName);
        $dbName = Utils::GetPath($dbPath);
        if (file_exists($dbName)) {
            $db = new SqliteDB();
            $db->Open($dbName);
            $vm = new SqliteVM($db);
            //Select all tests from the specified request type. Order tests using ExecuteSequence field
            if ($ent) {
                $rType = $requestType;
                $status = $vm->Execute("Select TestName, TestType from TestCase where TestType=\"{$rType}\" or TestType=\"{$requestType}\"order by ExecuteSequence");
            } else {
                $status = $vm->Execute("Select TestName, TestType from TestCase where TestType=\"{$requestType}\" order by ExecuteSequence");
            }
            while ($status == SQLITE_ROW) {
                $testName = $vm->GetString("TestName");
                $requestType = $vm->GetString("TestType");
                printf("Executing %s test: %s\n", $requestType, $testName);
                //File in the $_POST array to simulate a GET request that is  normally send by the HTML forms
                $_POST['testName'] = $testName;
                $_POST['requestType'] = $requestType;
                $_POST[$testName . ':dbPath'] = $dbPath;
                $result = new Run($testsRun);
                $exitStatus += $result->main($testsRun, $file);
                $status = $vm->NextRow();
            }
            unset($vm);
            unset($db);
            return $exitStatus;
        }
    } catch (SqliteException $s) {
        print $s->GetExceptionMessage();
        return 1;
    }
}