Esempio n. 1
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();
 }
Esempio n. 2
0
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;
    }
}