Пример #1
0
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
//
//This class executes a test case based on input received from the HTML forms
require_once "ExecuteOperation.php";
require_once "Validate.php";
require_once "Result.php";
require_once "HtmlPrinter.php";
require_once "Utils.php";
if (!defined('Run_MAIN_METHOD')) {
    define('Run_MAIN_METHOD', 'Run::main');
    $test = new Run();
    $testsRun = 0;
    $test->main($testsRun);
}
class Run
{
    //Define any private data members here
    private $unitTestVm;
    private $unitTestResultVm;
    private $apiCall;
    private $unitTestDb;
    private $validate;
    private $operation;
    public function main(&$testsRun, $file = null)
    {
        $status = -1;
        //Print HTML tags for the result page
        if ($_POST['output'] == "html") {
Пример #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;
    }
}