/** * * Add a new output reference to the test case instance data * @param KalturaTestDataBase $outputReference */ public function addOutputReference(KalturaTestDataBase $outputReference) { if ($this->outputReference == null) { $this->outputReference = array(); } $this->outputReference[$outputReference->getUniqueKey()] = $outputReference; }
/** * The main function for converting to an Domdocument. * Pass in a BaseObject (from kaltura) and returns that object serialized as a DomDocument * * @param KalturaTestDataObject $data * @param string $rootNodeName - what you want the root node to be - defaultsto data. * @return DomDocument XML */ public static function toXml(KalturaTestDataBase $data, $rootNodeName = 'data') { $dom = new DOMDocument(1.0); $rootNode = $dom->createElement($rootNodeName); $dom->appendChild($rootNode); foreach ($data->getAdditionalData() as $key => $value) { $rootNode->setAttribute($key, $value); } $dataObject = $data->getDataObject(); //we need to check if this is a propel object if (is_object($dataObject)) { if ($dataObject instanceof BaseObject) { //Gets the data peer of the object (used to geting all the obejct feilds) $dataPeer = $dataObject->getPeer(); //Gets all object fields $fields = call_user_func(array($dataPeer, "getFieldNames"), BasePeer::TYPE_PHPNAME); //Create the xml elements by all fields and their values foreach ($fields as $field) { $value = $dataObject->getByName($field); $comment = null; $comments = $data->getComments(); if (isset($comments[$field])) { $comment = $comments[$field]; } KalturaTestDataObject::createFieldElement($dom, $rootNode, $value, $field, null, $comment); } } else { $reflector = new ReflectionClass($data->getDataObject()); $properties = $reflector->getProperties(ReflectionProperty::IS_PUBLIC); $comments = $data->getComments(); foreach ($properties as $property) { $value = $property->getValue($data->getDataObject()); $propertyName = $property->getName(); $propertyValueType = null; if ($value != null) { $propertyValueType = gettype($value); if ($propertyValueType == "NULL") { $propertyValueType = null; //we null the type $class = get_class($value); if (class_exists($class)) { $propertyValueType = $class; } } } $comment = null; if (isset($comments[$propertyName])) { $comment = $comments[$propertyName]; } KalturaTestDataObject::createFieldElement($dom, $rootNode, $value, $propertyName, $propertyValueType, $comment); } } } else { //Value types will be written in the same line as their type } // pass back DomElement object return $dom; }