/**
  * 
  * Returns a DomDocument containing the test case failure
  * @param KalturaTestCaseInstanceFailure $failure
  * @param string $rootNodeName - default to 'data'
  * @return DOMDocument - the xml for the given error
  */
 public static function toXml(KalturaTestCaseInstanceFailure $testCaseInstanceFailure, $rootNodeName = 'data')
 {
     if (count($testCaseInstanceFailure->getFailures()) == 0) {
         return new DOMDocument("1.0");
     }
     $dom = new DOMDocument(1.0);
     $rootNode = $dom->createElement($rootNodeName);
     $dom->appendChild($rootNode);
     $rootNode->setAttribute("testCaseInstanceName", $testCaseInstanceFailure->getTestCaseInstanceName());
     $inputsNode = $dom->createElement("Inputs");
     foreach ($testCaseInstanceFailure->getTestCaseInput() as $inputKey => $inputValue) {
         $node = $dom->createElement("Input");
         if ($inputValue != null) {
             $type = gettype($inputValue);
             if (is_object($inputValue)) {
                 $class = get_class($inputValue);
                 KalturaLog::debug("class [" . $class . "]\n");
                 if (class_exists($class)) {
                     $type = get_class($inputValue);
                 }
             }
             $node->setAttribute("type", $type);
             $id = $inputValue;
             if ($inputValue instanceof BaseObject) {
                 $id = $inputValue->getId();
             } elseif ($inputValue instanceof KalturaObjectBase || $inputValue instanceof KalturaObject) {
                 if (property_exists($inputValue, 'id')) {
                     $id = $inputValue->id;
                 }
             }
             //Fixes problem where id was object
             if (is_object($id)) {
                 $idType = get_class($id);
                 $id = "not a string but {$idType}";
             }
             $node->setAttribute($type . "Id", $id);
         }
         $inputsNode->appendChild($node);
     }
     $failuresNode = $dom->createElement("Failures");
     foreach ($testCaseInstanceFailure->getFailures() as $kalturaFailure) {
         $objectAsDOM = KalturaFailure::toXml($kalturaFailure, "Failure");
         kXml::appendDomToElement($objectAsDOM, $failuresNode, $dom);
     }
     $rootNode->appendChild($inputsNode);
     $rootNode->appendChild($failuresNode);
     //pass back DomElement object
     return $dom;
 }
 /**	
  * 
  * Generates a new KalturaTestProcedureFailure object from a given SimpleXmlElement
  * @param string $failureFilePath
  */
 public function fromXml(SimpleXmlElement $xmlTestProcedure)
 {
     $this->testProcedureName = (string) $xmlTestProcedure["testProcedureName"];
     foreach ($xmlTestProcedure->TestCaseInstance as $unitTestFailureXml) {
         $testCaseInstanceFailure = KalturaTestCaseInstanceFailure::generateFromXml($unitTestFailureXml);
         $this->testCaseInstanceFailures[$testCaseInstanceFailure->getTestCaseInstanceName()] = $testCaseInstanceFailure;
     }
 }
 /**
  * 
  * Gets the test case instance data key
  * First by name and if name don't exists then by the test case inputs
  * @param KalturaTestCaseDataFile $newTestDataFile
  * @param KalturaTestCaseInstanceFailure $testCaseInstanceFailure
  */
 protected static function getTestCaseInstnaceKey(KalturaTestCaseDataFile $newTestDataFile, KalturaTestCaseInstanceFailure $testCaseInstanceFailure)
 {
     $testCaseInstanceKey = $testCaseInstanceFailure->getTestCaseInstanceName();
     //Check if key exists in the data file
     if (!$newTestDataFile->isTestCaseInstanceExists($testCaseInstanceKey)) {
         //If name doesn't exists we find the right input
         //TODO: maybe remove getTestKeyByInputs
         $testCaseInstanceKey = KalturaTestResultUpdater::getTestKeyByInputs($newTestDataFile, $testCaseInstanceFailure->getTestCaseInput());
     }
     return $testCaseInstanceKey;
 }