Пример #1
0
    find_folders($path);
}
foreach ($sub_folders as $folder) {
    $path = substr(__FILE__ . $folder, 0, strlen(__FILE__) - strlen("TEST.php"));
    chdir($path);
    foreach (glob($folder . "*.php") as $filename) {
        $parts = explode("/", $filename);
        $num_parts = count($parts);
        $just_name = $parts[$num_parts - 1];
        $path = substr(__FILE__ . $folder, 0, strlen(__FILE__) - strlen("TEST.php")) . $folder;
        chdir($path);
        require $filename;
    }
}
///////////////////////////////////////////////////////////
$T = new DaveTest("Test Suite Results", false);
$T->log("------------ TEST SUITE RESLTS ------------");
$T->log($__TEST_SUITE_RESULTS["Successes"] + $__TEST_SUITE_RESULTS["Failures"] . " total tests in " . (time() - $__TEST_SUITE_RESULTS["StartTime"]) . " seconds");
if ($__TEST_SUITE_RESULTS["Successes"] > 0) {
    $T->log($__TEST_SUITE_RESULTS["Successes"] . " passing tests");
} else {
    $T->log("0 passing tests");
}
if ($__TEST_SUITE_RESULTS["Failures"] > 0) {
    $T->log($__TEST_SUITE_RESULTS["Failures"] . " failing tests");
} else {
    $T->log("0 failing tests");
}
echo (int) ($__TEST_SUITE_RESULTS["Successes"] + $__TEST_SUITE_RESULTS["Failures"]) . "," . (int) $__TEST_SUITE_RESULTS["Successes"] . "," . (int) $__TEST_SUITE_RESULTS["Failures"];
echo "\r\n";
$T->end();
Пример #2
0
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I check a combination of API actions
***********************************************/
require_once "../spec_helper.php";
require $CONFIG['TableConfigFile'];
$__TABLES = $TABLES;
// needed because the user key changes depending on the DB type
$T = new DaveTest("End to End Test: Users");
// set some random values to ensure that this user doesn't exist already
$TestValues = array("ScreenName" => rand() . time() . "_name", "EMail" => rand() . time() . "@test.com");
$T->context("I should be able to create a user");
$PostArray = array("OutputType" => "PHP", "Action" => "UserAdd", "LimitLockPass" => $CONFIG['CorrectLimitLockPass'], "Password" => "password", "FirstName" => "DEMO", "LastName" => "TESTMAN", "ScreenName" => $TestValues['ScreenName'], "EMail" => $TestValues['EMail']);
$APIDATA = $T->api_request($PostArray);
$T->assert("==", $APIDATA["ERROR"], "OK");
$T->assert(">", $APIDATA[$__TABLES["users"]["META"]["KEY"]], 0);
$UserID = $APIDATA[$__TABLES["users"]["META"]["KEY"]];
$T->context("I should be able to View a user publicly");
$PostArray = array("OutputType" => "PHP", "Action" => "UserView", "LimitLockPass" => $CONFIG['CorrectLimitLockPass'], "ScreenName" => $TestValues['ScreenName']);
$APIDATA = $T->api_request($PostArray);
$T->assert("==", $APIDATA["ERROR"], "OK");
$T->assert("==", $APIDATA["User"]["InformationType"], "Public");
$T->assert("==", $APIDATA["User"]["ScreenName"], $TestValues['ScreenName']);
$T->assert("==", count($APIDATA["User"]), 3);
$T->context("I should be able to View a user privately");
$PostArray = array("OutputType" => "PHP", "Action" => "UserView", "LimitLockPass" => $CONFIG['CorrectLimitLockPass'], "ScreenName" => $TestValues['ScreenName'], "Password" => "password");
Пример #3
0
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I ensure that the various output types of the daveAPI work
***********************************************/
require_once "../spec_helper.php";
$T = new DaveTest("Output Types");
$T->context("The API should return various OutputTypes");
$T->context("PHP", 2);
$PostArray = array("OutputType" => "PHP", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$T->assert(">", count($APIDATA), 0);
$T->assert("==", $APIDATA["ERROR"], "That Action cannot be found.  Did you send the 'Action' parameter?  List Actions with Action=DescribeActions");
$T->context("JSON", 2);
$PostArray = array("OutputType" => "JSON", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$JSON_resp = json_decode($T->get_raw_api_respnse(), true);
$T->assert(">", count($JSON_resp), 0);
$T->assert("==", $JSON_resp["ERROR"], "That Action cannot be found.  Did you send the 'Action' parameter?  List Actions with Action=DescribeActions");
$T->context("XML", 2);
$PostArray = array("OutputType" => "XML", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$XML_resp = simplexml_load_string($T->get_raw_api_respnse());
$T->assert(">", count($XML_resp), 0);
$T->assert("==", $XML_resp->ERROR, "That Action cannot be found.  Did you send the 'Action' parameter?  List Actions with Action=DescribeActions");
$T->context("LINE", 2);
// CONSOLE and LINE are similar
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I check an API Action
***********************************************/
require_once "../spec_helper.php";
$T = new DaveTest("Describe Actions");
$PostArray = array("OutputType" => "PHP", "Action" => "DescribeActions", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$ExpectedActions = array("DescribeActions", "DescribeTables", "ObjectTest", "SlowAction", "CacheTest", "UserAdd", "UserView", "UserEdit", "UserEdit", "LogIn");
$T->context("There should be at least one Action returned");
$T->assert(">", count($APIDATA["Actions"]), 0);
$Actions = array();
foreach ($APIDATA["Actions"] as $Action) {
    $Actions[] = $Action["Name"];
}
$T->context("Certain Actions should be in the server results");
foreach ($ExpectedActions as $Action) {
    $T->assert("in_array", $Action, $Actions);
}
$T->end();
Пример #5
0
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I check an API Action
***********************************************/
require_once "../spec_helper.php";
$T = new DaveTest("Cache Test");
$T->context("The Action will error properly when no Hash is provided");
$PostArray = array("OutputType" => "PHP", "Action" => "CacheTest", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$T->assert("==", $APIDATA["ERROR"], "You need to provide a Hash");
$T->context("The Action will store the provided value in the cache");
$PostArray = array("OutputType" => "PHP", "Action" => "CacheTest", "hash" => "abc123", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$T->assert("==", $APIDATA["ERROR"], "OK");
$T->assert("==", $APIDATA["CachedResult"], "abc123");
$T->end();
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I check a combination of API actions
***********************************************/
require_once "../spec_helper.php";
$T = new DaveTest("End to End Test: Messages and Lobbies");
// set some random values to ensure that this user doesn't exist already
$TestValues = array("LobbyName" => rand() . time() . "_name");
$T->context("I should be able to create a lobby");
$PostArray = array("OutputType" => "PHP", "Action" => "LobbyAdd", "LobbyName" => $TestValues["LobbyName"]);
$APIDATA = $T->api_request($PostArray);
$T->assert("==", $APIDATA["ERROR"], "OK");
$T->assert("==", $APIDATA["LobbyName"], $TestValues["LobbyName"]);
$T->assert("==", strlen($APIDATA["LobbyKey"]), 32);
$TestValues["LobbyKey"] = $APIDATA["LobbyKey"];
// save for later tests
$T->context("I should be able to list lobbies, and my new lobby should be included");
$PostArray = array("OutputType" => "PHP", "Action" => "LobbyView");
$APIDATA = $T->api_request($PostArray);
$T->assert("==", $APIDATA["ERROR"], "OK");
$found = false;
foreach ($APIDATA["Lobbies"] as $Lobby) {
    if ($Lobby["LobbyName"] == $TestValues["LobbyName"]) {
        $found = true;
    }
}
Пример #7
0
<?php

/***********************************************
DAVE PHP API
https://github.com/evantahler/PHP-DAVE-API
Evan Tahler | 2011

I check general API functionality
***********************************************/
require_once "../spec_helper.php";
$T = new DaveTest("General API Tests");
$T->context("APIRequestsRemaining should decrement on subsequent loads");
$PostArray = array("OutputType" => "PHP");
$APIDATA = $T->api_request($PostArray);
$first = $APIDATA["APIRequestsRemaining"];
$T->assert(">", $first, 0);
$APIDATA = $T->api_request($PostArray);
$second = $APIDATA["APIRequestsRemaining"];
$T->assert(">", $second, 0);
$T->assert("<", $second, $first);
$T->context("computation time should be > 0s but less than 10s for rendering no Action");
$PostArray = array("OutputType" => "PHP", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$ComputationTime = $APIDATA["ComputationTime"];
$T->assert(">", $ComputationTime, 0);
$T->assert("<", $ComputationTime, 10);
$T->context("I should have an IP address");
$PostArray = array("OutputType" => "PHP", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIDATA = $T->api_request($PostArray);
$IP = $APIDATA["IP"];
$T->assert("==", $IP, "localhost");