/** * * Returns the test data file in XML format (including the objects) * @return string XML encoded representation of the test data file object */ public function toDataXML() { //TODO: Add the objects header $dom = new DOMDocument("1.0"); $dom->formatOutput = true; //Create elements in the Dom referencing the entire test data file $unitTestsElement = $dom->createElement("UnitTests"); $dom->appendChild($unitTestsElement); $unitTestsDataElement = $dom->createElement("UnitTestsData"); $unitTestsElement->appendChild($unitTestsDataElement); //For each unit test data foreach ($this->unitTestsData as $unitTestData) { //create all his elements $domUnitTestData = $dom->createElement("UnitTestData"); $unitTestsDataElement->appendChild($domUnitTestData); $inputs = $dom->createElement("Inputs"); $outputReferences = $dom->createElement("OutputReferences"); $domUnitTestData->appendChild($inputs); $domUnitTestData->appendChild($outputReferences); //for each input: foreach ($unitTestData->input as $input) { //Create the xml from the object $objectAsDOM = KalturaUnitTestDataObject::toXml($input, "Input"); if ($objectAsDOM->documentElement != NULL) { $importedNode = $dom->importNode($objectAsDOM->documentElement, true); //Add him to the input elements $inputs->appendChild($importedNode); } else { //Object is null so we make only an empty node! throw new Exception("One of the objects is null : " . $input); } } //for each outputReference: foreach ($unitTestData->outputReference as $outputReference) { //Create the xml from the object $objectAsDOM = KalturaUnitTestDataObject::toXml($outputReference, "OutputReference"); if ($objectAsDOM->documentElement != NULL) { $importedNode = $dom->importNode($objectAsDOM->documentElement, true); //Add him to the output reference elements $outputReferences->appendChild($importedNode); } else { //Object is null so we make only an empty node! throw new Exception("One of the objects is null : " . var_dump($outputReference)); } } $unitTestsDataElement->appendChild($domUnitTestData); } //return the XML well formated $dom->formatOutput = true; return $dom->saveXML(); }