Permalink
Browse files

adding tests for LINE output, removing DescribeActions output as defa…

…ult for API
  • Loading branch information...
Evan Tahler
Evan Tahler committed Apr 19, 2011
1 parent 10d342b commit a8a218d22b19078bdb4d03afa31ec35fab54cb15
Showing with 16 additions and 11 deletions.
  1. +1 −2 API/index.php
  2. +12 −3 SPEC/system/output_types.php
  3. +3 −6 script/{console → api}
View
@@ -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();
}
}
@@ -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();
@@ -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);

0 comments on commit a8a218d

Please sign in to comment.