浏览代码

#153 Finalized SOAP unit testing (local tests only)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@617 a333f486-631f-4898-b8df-5754b55c2be0
romainq 15 年之前
父节点
当前提交
137cf10ffe
共有 2 个文件被更改,包括 70 次插入41 次删除
  1. 67 40
      pages/testlist.inc.php
  2. 3 1
      webservices/webservices.class.inc.php

+ 67 - 40
pages/testlist.inc.php

@@ -1288,24 +1288,24 @@ $aWebServices = array(
 			'desc of ticket', /* sDescription */
 			'initial situation blah blah blah', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 				new SOAPLinkCreationSpec(
 					'InfrastructureCI',
-					array(new SOAPSearchCondition('id', 108)),
+					array(new SOAPSearchCondition('name', 'dbserver1.demo.com')),
 					array(new SOAPAttributeValue('impacting', 'very critical'))
 				),
 				new SOAPLinkCreationSpec(
 					'NetworkDevice',
-					array(new SOAPSearchCondition('name', 'Router03')),
+					array(new SOAPSearchCondition('name', 'switch01')),
 					array(new SOAPAttributeValue('impact', 'who cares'))
 				),
 				new SOAPLinkCreationSpec(
-					'Device',
+					'Server',
 					array(new SOAPSearchCondition('name', 'thisone')),
 					array(new SOAPAttributeValue('impact', 'our lives'))
 				),
@@ -1324,15 +1324,15 @@ $aWebServices = array(
 			'PC burning', /* sDescription */
 			'The power supply suddenly started to warm up', /* sInitialSituation */
 			new SOAPExternalKeySearch(), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 				new SOAPLinkCreationSpec(
 					'InfrastructureCI',
-					array(new SOAPSearchCondition('id', 1)),
+					array(new SOAPSearchCondition('name', 'dbserver1.demo.com')),
 					array()
 				), /* aImpact */
 			),
@@ -1343,18 +1343,18 @@ $aWebServices = array(
 	array(
 		'verb' => 'CreateIncidentTicket',
 		'expected result' => false,
-		'explain result' => 'wrong condition on CI to attach',
+		'explain result' => 'wrong class on CI to attach',
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
 			'PC burning', /* sDescription */
 			'The power supply suddenly started to warm up', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 				new SOAPLinkCreationSpec(
 					'logInfra',
@@ -1368,6 +1368,32 @@ $aWebServices = array(
 	),
 	array(
 		'verb' => 'CreateIncidentTicket',
+		'expected result' => false,
+		'explain result' => 'wrong search condition on CI to attach',
+		'args' => array(
+			'admin', /* sLogin */
+			'admin', /* sPassword */
+			'PC burning', /* sDescription */
+			'The power supply suddenly started to warm up', /* sInitialSituation */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
+			'sub product of the service', /* sProduct */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
+			array(
+				new SOAPLinkCreationSpec(
+					'InfrastructureCI',
+					array(new SOAPSearchCondition('dummyfiltercode', 2)),
+					array(new SOAPAttributeValue('impact', 'very critical'))
+				),
+			), /* aImpact */
+			'1', /* sImpact */
+			'1', /* sUrgency */
+		),
+	),
+	array(
+		'verb' => 'CreateIncidentTicket',
 		'expected result' => true,
 		'explain result' => 'no CI to attach (empty array)',
 		'args' => array(
@@ -1376,11 +1402,11 @@ $aWebServices = array(
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
 			'1', /* sImpact */
@@ -1397,13 +1423,12 @@ $aWebServices = array(
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
-			array(
-			), /* aImpact */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
+			null,  /* aImpact */
 			'1', /* sImpact */
 			'1', /* sUrgency */
 		),
@@ -1418,11 +1443,11 @@ $aWebServices = array(
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1000))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
 			'1', /* sImpact */
@@ -1432,22 +1457,22 @@ $aWebServices = array(
 	array(
 		'verb' => 'CreateIncidentTicket',
 		'expected result' => false,
-		'explain result' => 'wrong values for type and severity',
+		'explain result' => 'wrong values for impact and urgency',
 		'args' => array(
 			'admin', /* sLogin */
 			'admin', /* sPassword */
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
-			'1', /* sImpact */
-			'1', /* sUrgency */
+			'6', /* sImpact */
+			'7', /* sUrgency */
 		),
 	),
 	array(
@@ -1460,11 +1485,11 @@ $aWebServices = array(
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
 			'1', /* sImpact */
@@ -1481,11 +1506,11 @@ $aWebServices = array(
 			'Houston not reachable', /* sDescription */
 			'Tried to join the shuttle', /* sInitialSituation */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aCallerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 2))), /* aCustomerDesc */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 4))), /* aServiceDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Demo'))), /* aCustomerDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'HW Management'))), /* aServiceDesc */
 			new SOAPExternalKeySearch(array(new SOAPSearchCondition('id', 1))), /* aServiceSubcategoryDesc */
 			'sub product of the service', /* sProduct */
-			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'FLS Desktop'))), /* aWorkgroupDesc */
+			new SOAPExternalKeySearch(array(new SOAPSearchCondition('name', 'Hardware support'))), /* aWorkgroupDesc */
 			array(
 			), /* aImpact */
 			'1', /* sImpact */
@@ -1529,7 +1554,8 @@ class TestSoap extends TestSoapWebService
 		global $aWebServices;
 		foreach ($aWebServices as $iPos => $aWebService)
 		{
-			echo "<h4>SOAP call #$iPos ".$aWebService['explain result']."</h4>\n";
+			echo "<h2>SOAP call #$iPos - {$aWebService['verb']}</h2>\n";
+			echo "<p>{$aWebService['explain result']}</p>\n";
 
 			try
 			{
@@ -1582,9 +1608,10 @@ class TestWebServicesDirect extends TestBizModel
 		$oWebServices = new WebServices();
 
 		global $aWebServices;
-		foreach ($aWebServices as $i => $aWebService)
+		foreach ($aWebServices as $iPos => $aWebService)
 		{
-			echo "<h2>Test #$i - {$aWebService['verb']} </h2>\n";
+			echo "<h2>SOAP call #$iPos - {$aWebService['verb']}</h2>\n";
+			echo "<p>{$aWebService['explain result']}</p>\n";
 			$oRes = call_user_func_array(array($oWebServices, $aWebService['verb']), $aWebService['args']);
 			echo "<pre>\n";
 			print_r($oRes);

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

@@ -487,7 +487,7 @@ class WebServices
 			if ($bRes)
 			{
 				$iId = $oTargetObj->DBInsertTrackedNoReload($oChange);
-				$oRes->LogInfo("Created object ".get_class($$oTargetObj)."::$iId");
+				$oRes->LogInfo("Created object ".get_class($oTargetObj)."::$iId");
 				$oRes->AddResultObject($sResultLabel, $oTargetObj);
 			}
 			else
@@ -558,7 +558,9 @@ class WebServices
 		$aServiceDesc = self::SoapStructToExternalKeySearch($oServiceDesc);
 		$aServiceSubcategoryDesc = self::SoapStructToExternalKeySearch($oServiceSubcategoryDesc);
 		$aWorkgroupDesc = self::SoapStructToExternalKeySearch($oWorkgroupDesc);
+
 		$aImpactedCIs = array();
+		if (is_null($aSOAPImpactedCIs)) $aSOAPImpactedCIs = array();
 		foreach($aSOAPImpactedCIs as $oImpactedCIs)
 		{
 			$aImpactedCIs[] = self::SoapStructToLinkCreationSpec($oImpactedCIs);