00001 <?php 00010 require_once("safely-php/assert.php"); 00011 require_once("models/WSCORE2.php"); 00012 require_once("models/soc1c.php"); 00013 00014 $expected_no = 3; 00015 $completed_no = 0; 00016 00020 function testBasicMethods () { 00021 global $assert; 00022 global $completed_no; 00023 00024 $conf = new WSCORE2(); 00025 $conf->set("soc_namespace", "http://tempuri.org/"); 00026 $conf->set("soc_wsdl", "https://camel2.usc.edu/SOC-WS/soc-ws.asmx"); 00027 $conf->set("iui_wsdl", "https://camel2.usc.edu/SOC-WS/iui-ws.asmx"); 00028 00029 $assert->isTrue($conf->get("soc_namespace") === "http://tempuri.org/", "Configuration should have been set to http://tempuri.org/ for soc_namespace"); 00030 $obj = new SOC_Widget($conf); 00031 $assert->isTrue($obj->get("soc_namespace") == $conf->get("soc_namespace"), "Namespace should be set to ".$conf->get("soc_namespace")." but found ".$obj->get("soc_namespace")); 00032 $completed_no += 1; 00033 } 00034 00038 function testSOC_Configuration () { 00039 global $assert; 00040 global $completed_no; 00041 00042 $conf = new SOC_Configuration("Test SOC API1C","soc1c.conf"); 00043 $assert->isTrue($conf->get("soc_namespace") !== false, "Should have soc_namespace set if configuration was read properly."); 00044 00045 $obj = new SOC_Widget($conf); 00046 $assert->isTrue($conf->get("soc_namespace") === $obj->get("soc_namespace"), "Should have soc_namespace set in new obj of class SOC_Widget."); 00047 $assert->isTrue($obj->version() === "SOC1C", "Should have version set."); 00048 $completed_no += 1; 00049 } 00050 00051 if (php_sapi_name() !== 'cli') { 00052 echo 'This should be run from the command line.'; 00053 exit(1); 00054 } 00055 echo 'Starting [soc1c-tests.php] ...' . PHP_EOL; 00056 echo "\tstarting, testBasicMethods() $completed_no/$expected_no\n"; 00057 testBasicMethods(); 00058 echo "\tstarting, testSOC_Configuration() $completed_no/$expected_no\n"; 00059 testSOC_Configuration(); 00060 echo "Success!! completed $completed_no/$expected_no" . PHP_EOL; 00061 ?>