Skip to content

Commit

Permalink
adding tests for LINE output, removing DescribeActions output as defa…
Browse files Browse the repository at this point in the history
…ult for API
  • Loading branch information
Evan Tahler committed Apr 19, 2011
1 parent 10d342b commit a8a218d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 1 addition & 2 deletions API/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,8 @@
if ($ActionPreformed == 0 || $PARAMS["Action"] == "" || strlen($PARAMS["Action"]) == 0)
{
if ($ERROR == 100) {
$ERROR = "That Action cannot be found. Did you send the 'Action' parameter?";
$ERROR = "That Action cannot be found. Did you send the 'Action' parameter? List Actions with Action=DescribeActions";
$Action = "Unknown Action";
$OUTPUT["KnownActions"] = humanize_actions();
}
}

Expand Down
15 changes: 12 additions & 3 deletions SPEC/system/output_types.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,32 @@
$APIRequest = new APIRequest($TestURL, $PostArray);
$APIDATA = $APIRequest->DoRequest();
$T->assert(">",count($APIDATA),0);
$T->assert("==",$APIDATA["ERROR"],"That Action cannot be found. Did you send the 'Action' parameter?");
$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']);
$APIRequest = new APIRequest($TestURL, $PostArray);
$APIRequest->DoRequest();
$JSON_resp = json_decode($APIRequest->ShowRawResponse(), true);
$T->assert(">",count($JSON_resp),0);
$T->assert("==",$JSON_resp["ERROR"],"That Action cannot be found. Did you send the 'Action' parameter?");
$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']);
$APIRequest = new APIRequest($TestURL, $PostArray);
$APIRequest->DoRequest();
$XML_resp = simplexml_load_string($APIRequest->ShowRawResponse());
$T->assert(">",count($XML_resp),0);
$T->assert("==",$XML_resp->ERROR,"That Action cannot be found. Did you send the 'Action' parameter?");
$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
$PostArray = array("OutputType" => "LINE", "LimitLockPass" => $CONFIG['CorrectLimitLockPass']);
$APIRequest = new APIRequest($TestURL, $PostArray);
$APIRequest->DoRequest();
$Lines = explode("\r\n",$APIRequest->ShowRawResponse());
$T->assert(">",count($Lines),0);
$T->assert("==",$Lines[2],"Action: Unknown Action");
$T->assert("==",$Lines[8],"ERROR: That Action cannot be found. Did you send the 'Action' parameter? List Actions with Action=DescribeActions");

$T->end();

Expand Down
9 changes: 3 additions & 6 deletions script/console → script/api
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
#!/usr/bin/env php
<?php
// I will allow you to use the command line to interact with DAVE. Pass params with standard command line-style input (ie: --key1=val1 --key2=val2 OR -key1=val1 -key2=val2). Variables passed this way will be available in $_GET, $_POST, $_COOKIE, and $_POST.
// I will allow you to use the command line to interact with DAVE. Pass params with standard command line-style input (ie: --key1=val1 --key2=val2). Variables passed this way will be available in $_GET, $_POST, $_COOKIE, and $_POST.

require("API/helper_functions/parseArgs.php");

$__args = __parseArgs();
$__args["IP"] = "Console";
if (empty($__args["OutputType"]))
{
$__args["OutputType"] = "CONSOLE";
}
if (empty($__args["IP"])){ $__args["IP"] = "localhost"; }
if (empty($__args["OutputType"])){ $__args["OutputType"] = "CONSOLE"; }

$_GET = $_POST = $_COOKIE = $_REQUEST = $__args ;
unset($__args);
Expand Down

0 comments on commit a8a218d

Please sign in to comment.