/**
  * 
  * Update the failures into the data so in the next run no failures will accure
  * Should be use with extreme care after completly reviewing the failure file  
  * @param unknown_type $dataFile
  * @param unknown_type $failuresFile
  */
 public static function UpdateResults($dataFilePath, $failuresFilePath)
 {
     //Returns the inputs for the unit tests
     KalturaLog::debug("dataFilePath [{$dataFilePath}], failuresFilePath [{$failuresFilePath}]\n");
     $oldFilesIndex = KalturaTestResultUpdater::getLastDataFileIndex($dataFilePath);
     copy($dataFilePath, $dataFilePath . ".old" . $oldFilesIndex);
     $oldTestDataFile = KalturaTestCaseDataFile::generateFromDataXml($dataFilePath);
     $testsFailures = KalturaTestCaseFailures::generateFromXml($failuresFilePath);
     $newTestDataFile = KalturaTestResultUpdater::update($oldTestDataFile, $testsFailures);
     $newTestDataDom = KalturaTestCaseDataFile::toXml($newTestDataFile);
     $newDataFile = fopen($dataFilePath, "w+");
     $newTestDataDom->formatOutput = true;
     KalturaLog::debug("Writing new test data file [" . $newTestDataDom->saveXML() . "]");
     fwrite($newDataFile, $newTestDataDom->saveXML());
 }
 /**
  * 
  * Creates a test file from the given KalturaTestCaseDataFile object (the data source for the test)
  * @param testDataFile $testDataFile
  */
 private function createTestDataFile(KalturaTestCaseDataFile $testDataSourceFile)
 {
     //TODO: break this function to 2 parts!
     //1. Create the new test data file
     $newTestDataFile = new KalturaTestCaseDataFile($testDataSourceFile->getTestCaseName());
     //2.For every test data we need to:
     foreach ($testDataSourceFile->getTestProceduresData() as $testProcedureData) {
         $newTestProcedureData = new KalturaTestProcedureData($testProcedureData->getProcedureName());
         foreach ($testProcedureData->getTestCasesData() as $testCaseData) {
             $newTestCaseData = new KalturaTestCaseInstanceData($testCaseData->getTestCaseInstanceName());
             //2. Foreach input - Get the object from kaltura DB and add it to the inputObjects array
             foreach ($testCaseData->getInput() as $inputIdentifier) {
                 $inputObject = $this->getTestDataObject($inputIdentifier);
                 $newTestCaseData->addInput($inputObject);
             }
             //3. Foreach outputReference - Get the object from kaltura DB and add it to the outputReferenceObjects array
             foreach ($testCaseData->getOutputReferences() as $outputReferenceIdentifier) {
                 $outputReferenceObject = $this->getTestDataObject($outputReferenceIdentifier);
                 $newTestCaseData->addOutputReference($outputReferenceObject);
             }
             //5. Add the new unit test data to the Data file
             $newTestProcedureData->addTestCaseInstance($newTestCaseData);
         }
         $newTestDataFile->addTestProcedureData($newTestProcedureData);
     }
     chdir(dirname($this->dataSourceFile->getFilePath()));
     //3. Open the file at the file path
     $testDatFileHandle = fopen("{$testDataSourceFile->getTestCaseName()}.data", "w+");
     //4. Convert the test data to xml dom
     $newTestDataDom = KalturaTestCaseDataFile::toXml($newTestDataFile);
     $newTestDataDom->formatOutput = true;
     //5. Save the entire test data file to the test data file name path (in XML)
     fwrite($testDatFileHandle, $newTestDataDom->saveXML());
 }