-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1bf03ac
commit c99d4ad
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/* load simpletest library | ||
downloadable using | ||
wget http://downloads.sourceforge.net/project/simpletest/simpletest/simpletest_1.1/simpletest_1.1alpha3.tar.gz; | ||
tar -zxf simpletest_1.1alpha3.tar.gz; | ||
*/ | ||
require_once('simpletest/autorun.php'); | ||
// load baseclass | ||
require_once('APIBaseClass.php'); | ||
// load your class here... | ||
require_once('toxnetApi.php'); | ||
// the name of the api class is 'yourApi' | ||
class TestOfApiClass extends UnitTestCase { | ||
public $api; | ||
// put your class name here | ||
public static $class_name = 'toxnetApi'; | ||
function testApiConstructs(){ | ||
$this->api = new self::$class_name(); | ||
$this->check_class_params('_http _root api_url'); | ||
} | ||
|
||
function check_class_params($params=NULL,$mode=TRUE){ | ||
// look up parameters inside of class and see if they are set/ true | ||
// also allow to only check for certain parameters by passing in an array with the names of those variables or a space seperated string | ||
// parameters to look for in the object | ||
$api_class_vars = get_class_vars(get_class($this->api)); | ||
if($params != null && is_string($params)){ | ||
$params = explode(' ',$params); | ||
foreach($params as $key_name) | ||
$api_vars [$key_name] = "$key_name"; | ||
$api_vars = array_intersect_key($api_class_vars,$api_vars); | ||
} | ||
else | ||
$api_vars = $api_class_vars; | ||
// anything that isnt intersected should return false | ||
|
||
foreach($api_vars as $key=>$value){ | ||
if($mode == TRUE) | ||
$this->assertTrue(array_key_exists($key,$api_class_vars)); | ||
elseif($mode == FALSE) | ||
$this->assertFalse(array_key_exists($key,$api_class_vars)); | ||
} | ||
} | ||
} | ||
?> | ||
|