示例#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();
 }
示例#2
0
文件: Utils.php 项目: kanbang/Colt
 public static function GetDbPath($dumpFileName)
 {
     $db = new SqliteDB();
     $dbPath = substr($dumpFileName, 0, strpos($dumpFileName, ".dump")) . ".db";
     $dbName = Utils::GetPath($dbPath);
     $dumpFileName = Utils::GetPath($dumpFileName);
     //Clear the stat cache as filemtime may not work correctly
     clearstatcache();
     //If we do not have neither a dump file nor a database file we are stuck.
     if (!file_exists($dumpFileName) && !file_exists($dbName)) {
         printf("<b>Error: Dump file <i>%s</i> not found. Unable to create database file</b><br />", $dumpFileName);
     } elseif (!file_exists($dbName)) {
         $db->GenerateDatabase($dumpFileName, $dbName);
     } elseif (file_exists($dumpFileName) && filemtime($dumpFileName) > filemtime($dbName)) {
         //Try to delete the database and if you cannot than do not create a new database as this will result in duplicate records
         if (@unlink($dbName)) {
             $db->GenerateDatabase($dumpFileName, $dbName);
         } else {
             printf("<b>Unable to delete database file <i>%s</i>. The file is either in use or is read only.</b><br />", $dbName);
             print "<b>The database has not been updated!</b><br />";
         }
     }
     return $dbPath;
 }
示例#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;
    }
}