/** * * Update the data with the given failure * @param KalturaTestCaseDataFile $unitTestData * @param KalturaTestCaseFailures $testsFailures * @return KalturaTestCaseDataFile - The new unitTestDataFile with the changes */ private static function update(KalturaTestCaseDataFile $testDataFile, KalturaTestCaseFailures $testCaseFailures) { //TODO: check this for no errors $newTestDataFile = unserialize(serialize($testDataFile)); //For each test procedure failure foreach ($testCaseFailures->getTestProceduresFailures() as $testProcedureFailures) { //Get the test procedure name / key $testProcedureName = $testProcedureFailures->getTestProcedureName(); KalturaLog::debug("testProcedureName [" . $testProcedureName . "]\n"); foreach ($testProcedureFailures->getTestCaseInstanceFailures() as $testCaseInstanceFailure) { $testCaseInstanceKey = KalturaTestResultUpdater::getTestCaseInstnaceKey($newTestDataFile, $testCaseInstanceFailure); KalturaLog::debug("testCaseInstanceKey [" . $testCaseInstanceKey . "]\n"); //If key wasnt found skip the error if (is_null($testCaseInstanceKey)) { KalturaLog::debug("Test case instance wasn't found [" . print_r($testCaseInstanceFailure, true) . "] "); KalturaLog::debug("Skipping failure!!!"); continue; } //Update the values by its failures foreach ($testCaseInstanceFailure->getFailures() as $failure) { $field = $failure->getField(); $actualValue = $failure->getActualValue(); $testProcedureData = $newTestDataFile->getTestProcedureData($testProcedureName); $testCaseInstanceData = $testProcedureData->getTestCaseData($testCaseInstanceKey); //Gets the first output reference $outputReferenceObject = $testCaseInstanceData->getOutputReference(0); //We update only the first output reference which is propel $outputReferenceObject->setByName($field, $actualValue); //If there are no dbValues yet we create the first ones $oldComments = $outputReferenceObject->getComments(); if (!isset($oldComments[$field])) { $outputReferenceObject->addComment($field, $failure->getOutputReferenceValue()); } } } } return $newTestDataFile; }