瀏覽代碼

Test: fixed automated tests that were abusively failing due to a few new magic attributes

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4746 a333f486-631f-4898-b8df-5754b55c2be0
romainq 8 年之前
父節點
當前提交
79fb8d0040
共有 1 個文件被更改,包括 39 次插入153 次删除
  1. 39 153
      test/testlist.inc.php

+ 39 - 153
test/testlist.inc.php

@@ -3635,7 +3635,39 @@ class TestEmailAsynchronous extends TestBizModel
 	}
 	}
 }
 }
 
 
-class TestLinkSetRecording_NN_WithDuplicates extends TestBizModel
+abstract class TestLinkSet extends TestBizModel
+{
+	protected function StandardizedDump($oSet, $sAttPrefixToIgnore)
+	{
+		if (!$oSet->m_bLoaded) $oSet->Load();
+		$oSet->Rewind();
+
+		$aRet = array();
+		while($oObject = $oSet->Fetch())
+		{
+			$aValues = array();
+			foreach(MetaModel::ListAttributeDefs(get_class($oObject)) as $sAttCode => $oAttDef)
+			{
+				//if (!$oAttDef->IsPartOfFingerprint()) continue;
+				//if ($oAttDef->IsMagic()) continue;
+				if ($sAttCode == 'friendlyname') continue;
+				if (substr($sAttCode, -strlen('_archive_flag')) == '_archive_flag') continue;
+				if (substr($sAttCode, -strlen('_obsolescence_flag')) == '_obsolescence_flag') continue;
+				if (substr($sAttCode, 0, strlen($sAttPrefixToIgnore)) == $sAttPrefixToIgnore) continue;
+				if ($oAttDef->IsScalar())
+				{
+					$aValues[] = $oObject->Get($sAttCode);
+				}
+			}
+			$aRet[] = implode(', ', $aValues);
+		}
+		sort($aRet);
+		return $aRet;
+	}
+
+}
+
+class TestLinkSetRecording_NN_WithDuplicates extends TestLinkSet
 {
 {
 	static public function GetName()
 	static public function GetName()
 	{
 	{
@@ -3916,69 +3948,19 @@ class TestLinkSetRecording_NN_WithDuplicates extends TestBizModel
 					array(
 					array(
 						'networkdevice_id' => $iDev2,
 						'networkdevice_id' => $iDev2,
 						'connectableci_id' => $iServer,
 						'connectableci_id' => $iServer,
-						'network_port' => '',
-						'device_port' => '',
-					),
-				),
-				'expected-res' => array (
-					"$iDev2, test device B, unit test linkset, , , downlink, test device B",
-				),
-				'history_added' => 1,
-				'history_removed' => 0,
-				'history_modified' => 0,
-			),
-			array(
-				'description' => 'Create a second link from scratch, pointing to the same server and no port, to prepare for the next test case',
-				'links' => array(
-					array(
-						'id' => "SELECT lnkConnectableCIToNetworkDevice WHERE networkdevice_id = $iDev2 AND connectableci_id = $iServer",
-						'networkdevice_id' => $iDev2,
-						'connectableci_id' => $iServer,
-						'network_port' => '',
-						'device_port' => '',
-					),
-					array(
-						'networkdevice_id' => $iDev2,
-						'connectableci_id' => $iServer,
-						'network_port' => 'X',
-						'device_port' => '',
-					),
-				),
-				'expected-res' => array (
-					"$iDev2, test device B, unit test linkset, , , downlink, test device B",
-					"$iDev2, test device B, unit test linkset, X, , downlink, test device B",
-				),
-				'history_added' => 1,
-				'history_removed' => 0,
-				'history_modified' => 0,
-			),
-			array(
-				'description' => 'Create a second link from scratch, pointing to the same server and no port, to prepare for the next test case',
-				'links' => array(
-					array(
-						'id' => "SELECT lnkConnectableCIToNetworkDevice WHERE networkdevice_id = $iDev2 AND connectableci_id = $iServer",
-						'networkdevice_id' => $iDev2,
-						'connectableci_id' => $iServer,
-						'network_port' => '',
-						'device_port' => '',
-					),
-					array(
-						'networkdevice_id' => $iDev2,
-						'connectableci_id' => $iServer,
-						'network_port' => 'X',
+						'network_port' => 'portX',
 						'device_port' => '',
 						'device_port' => '',
 					),
 					),
 				),
 				),
 				'expected-res' => array (
 				'expected-res' => array (
-					"$iDev2, test device B, unit test linkset, , , downlink, test device B",
-					"$iDev2, test device B, unit test linkset, X, , downlink, test device B",
+					"$iDev2, test device B, unit test linkset, portX, , downlink, test device B",
 				),
 				),
 				'history_added' => 1,
 				'history_added' => 1,
 				'history_removed' => 0,
 				'history_removed' => 0,
 				'history_modified' => 0,
 				'history_modified' => 0,
 			),
 			),
 			array(
 			array(
-				'description' => 'Device B twice (same characteristics) - known issue #1145',
+				'description' => 'Device B twice (same characteristics) - known issue #1145 (test failing until we fix it)',
 				'links' => array(
 				'links' => array(
 					array(
 					array(
 						'networkdevice_id' => $iDev2,
 						'networkdevice_id' => $iDev2,
@@ -4092,33 +4074,9 @@ class TestLinkSetRecording_NN_WithDuplicates extends TestBizModel
 			}
 			}
 		}
 		}
 	}
 	}
-
-	protected function StandardizedDump($oSet, $sAttPrefixToIgnore)
-	{
-		if (!$oSet->m_bLoaded) $oSet->Load();
-		$oSet->Rewind();
-	
-		$aRet = array();
-		while($oObject = $oSet->Fetch())
-		{
-			$aValues = array();
-			foreach(MetaModel::ListAttributeDefs(get_class($oObject)) as $sAttCode => $oAttDef)
-			{
-				if ($sAttCode == 'friendlyname') continue;
-				if (substr($sAttCode, 0, strlen($sAttPrefixToIgnore)) == $sAttPrefixToIgnore) continue;
-				if ($oAttDef->IsScalar())
-				{
-					$aValues[] = $oObject->Get($sAttCode);
-				}
-			}
-			$aRet[] = implode(', ', $aValues);
-		}
-		sort($aRet);
-		return $aRet;
-	}
 }
 }
 
 
-class TestLinkSetRecording_NN_NoDuplicates extends TestBizModel
+class TestLinkSetRecording_NN_NoDuplicates extends TestLinkSet
 {
 {
 	static public function GetName()
 	static public function GetName()
 	{
 	{
@@ -4435,33 +4393,9 @@ class TestLinkSetRecording_NN_NoDuplicates extends TestBizModel
 			}
 			}
 		}
 		}
 	}
 	}
-
-	protected function StandardizedDump($oSet, $sAttPrefixToIgnore)
-	{
-		if (!$oSet->m_bLoaded) $oSet->Load();
-		$oSet->Rewind();
-	
-		$aRet = array();
-		while($oObject = $oSet->Fetch())
-		{
-			$aValues = array();
-			foreach(MetaModel::ListAttributeDefs(get_class($oObject)) as $sAttCode => $oAttDef)
-			{
-				if ($sAttCode == 'friendlyname') continue;
-				if (substr($sAttCode, 0, strlen($sAttPrefixToIgnore)) == $sAttPrefixToIgnore) continue;
-				if ($oAttDef->IsScalar())
-				{
-					$aValues[] = $oObject->Get($sAttCode);
-				}
-			}
-			$aRet[] = implode(', ', $aValues);
-		}
-		sort($aRet);
-		return $aRet;
-	}
 }
 }
 
 
-class TestLinkSetRecording_1N extends TestBizModel
+class TestLinkSetRecording_1N extends TestLinkSet
 {
 {
 	static public function GetName()
 	static public function GetName()
 	{
 	{
@@ -4663,34 +4597,10 @@ class TestLinkSetRecording_1N extends TestBizModel
 			}
 			}
 		}
 		}
 	}
 	}
-
-	protected function StandardizedDump($oSet, $sAttPrefixToIgnore)
-	{
-		if (!$oSet->m_bLoaded) $oSet->Load();
-		$oSet->Rewind();
-
-		$aRet = array();
-		while($oObject = $oSet->Fetch())
-		{
-			$aValues = array();
-			foreach(MetaModel::ListAttributeDefs(get_class($oObject)) as $sAttCode => $oAttDef)
-			{
-				if ($sAttCode == 'friendlyname') continue;
-				if (substr($sAttCode, 0, strlen($sAttPrefixToIgnore)) == $sAttPrefixToIgnore) continue;
-				if ($oAttDef->IsScalar())
-				{
-					$aValues[] = $oObject->Get($sAttCode);
-				}
-			}
-			$aRet[] = implode(', ', $aValues);
-		}
-		sort($aRet);
-		return $aRet;
-	}
 }
 }
 
 
 
 
-class TestLinkSetRecording_1NAdd_Remove extends TestBizModel
+class TestLinkSetRecording_1NAdd_Remove extends TestLinkSet
 {
 {
 	static public function GetName()
 	static public function GetName()
 	{
 	{
@@ -4908,30 +4818,6 @@ class TestLinkSetRecording_1NAdd_Remove extends TestBizModel
 			}
 			}
 		}
 		}
 	}
 	}
-
-	protected function StandardizedDump($oSet, $sAttPrefixToIgnore)
-	{
-		if (!$oSet->m_bLoaded) $oSet->Load();
-		$oSet->Rewind();
-
-		$aRet = array();
-		while($oObject = $oSet->Fetch())
-		{
-			$aValues = array();
-			foreach(MetaModel::ListAttributeDefs(get_class($oObject)) as $sAttCode => $oAttDef)
-			{
-				if ($sAttCode == 'friendlyname') continue;
-				if (substr($sAttCode, 0, strlen($sAttPrefixToIgnore)) == $sAttPrefixToIgnore) continue;
-				if ($oAttDef->IsScalar())
-				{
-					$aValues[] = $oObject->Get($sAttCode);
-				}
-			}
-			$aRet[] = implode(', ', $aValues);
-		}
-		sort($aRet);
-		return $aRet;
-	}
 }
 }
 
 
 class TestDateTimeFormats extends TestBizModel
 class TestDateTimeFormats extends TestBizModel