Browse Source

Finalized web services (unit tests, sample client) and dehardcoded the GetVersion() verb

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@618 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 years ago
parent
commit
c89303a76d
3 changed files with 40 additions and 8 deletions
  1. 25 4
      pages/testlist.inc.php
  2. 1 1
      webservices/itopsoap.examples.php
  3. 14 3
      webservices/webservices.class.inc.php

+ 25 - 4
pages/testlist.inc.php

@@ -1274,8 +1274,8 @@ class TestItopWebServices extends TestWebServices
 $aWebServices = array(
 	array(
 		'verb' => 'GetVersion',
-		'expected result' => '0.8',
-		'explain result' => 'n/a',
+		'expected result' => WebServices::GetVersion(),
+		'explain result' => 'no comment!',
 		'args' => array(),
 	),
 	array(
@@ -1316,7 +1316,7 @@ $aWebServices = array(
 	),
 	array(
 		'verb' => 'CreateIncidentTicket',
-		'expected result' => false,
+		'expected result' => true,
 		'explain result' => 'caller not specified',
 		'args' => array(
 			'admin', /* sLogin */
@@ -1435,7 +1435,7 @@ $aWebServices = array(
 	),
 	array(
 		'verb' => 'CreateIncidentTicket',
-		'expected result' => false,
+		'expected result' => true,
 		'explain result' => 'caller unknown',
 		'args' => array(
 			'admin', /* sLogin */
@@ -1590,6 +1590,10 @@ class TestSoap extends TestSoapWebService
 			}
 			if ($res != $aWebService['expected result'])
 			{
+				echo "Expecting:<br/>\n";
+				var_dump($aWebService['expected result']);
+				echo "Obtained:<br/>\n";
+				var_dump($res);
 				throw new UnitTestException("Expecting result '{$aWebService['expected result']}', but got '$res'");
 			}
 		} 
@@ -1616,6 +1620,23 @@ class TestWebServicesDirect extends TestBizModel
 			echo "<pre>\n";
 			print_r($oRes);
 			echo "</pre>\n";
+
+			if ($oRes instanceof SOAPResult)
+			{
+				$res = $oRes->status;
+			}
+			else
+			{
+				$res = $oRes;
+			}
+			if ($res != $aWebService['expected result'])
+			{
+				echo "Expecting:<br/>\n";
+				var_dump($aWebService['expected result']);
+				echo "Obtained:<br/>\n";
+				var_dump($res);
+				throw new UnitTestException("Expecting result '{$aWebService['expected result']}', but got '$res'");
+			}
 		}
 		return true;
 	}

+ 1 - 1
webservices/itopsoap.examples.php

@@ -56,7 +56,7 @@ try
 		'HW found shutdown', /* description */
 		null, /* caller */
 		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* customer */
-		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW Mgmt'))), /* service */
+		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW Management'))), /* service */
 		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Troubleshooting'))), /* service subcategory */
 		'', /* product */
 		new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'NW support'))), /* workgroup */

+ 14 - 3
webservices/webservices.class.inc.php

@@ -498,8 +498,9 @@ class WebServices
 	}
 
 
-	static protected function SoapStructToExternalKeySearch(SoapExternalKeySearch $oExternalKeySearch)
+	static protected function SoapStructToExternalKeySearch($oExternalKeySearch)
 	{
+		if (is_null($oExternalKeySearch)) return null;
 		if ($oExternalKeySearch->IsVoid()) return null;
 
 		$aRes = array();
@@ -538,9 +539,19 @@ class WebServices
 	 *	 
 	 * @return WebServiceResult
 	 */
-	public function GetVersion()
+	static public function GetVersion()
 	{
-		return "0.8";
+		if (ITOP_REVISION == '$WCREV$')
+		{
+			$sVersionString = ITOP_VERSION.' [dev]';
+		}
+		else
+		{
+			// This is a build made from SVN, let display the full information
+			$sVersionString = ITOP_VERSION."-".ITOP_REVISION." ".ITOP_BUILD_DATE;
+		}
+
+		return $sVersionString;
 	}
 
 	public function CreateIncidentTicket($sLogin, $sPassword, $sTitle, $sDescription, $oCallerDesc, $oCustomerDesc, $oServiceDesc, $oServiceSubcategoryDesc, $sProduct, $oWorkgroupDesc, $aSOAPImpactedCIs, $sImpact, $sUrgency)