/** * @covers WindowsAzure\MediaServices\Internal\ContentPropertiesSerializer::serialize * @covers WindowsAzure\MediaServices\Internal\ContentPropertiesSerializer::_serializeRecursive */ public function testSerializeCollection() { // Setup $taskBodyKey = 'TaskBody'; $taskBody = 'TaskBody'; $optionsKey = 'Options'; $options = TaskOptions::NONE; $mediaProcessorIdKey = 'MediaProcessorId'; $mediaProcessorId = 'MediaProcessorId'; $errorKey = 'ErrorDetails'; $errorCodeKey = 'Code'; $errorCode = 1; $errorMessageKey = 'Message'; $errorMessage = 'Error message'; $error = array(array($errorCodeKey => $errorCode, $errorMessageKey => $errorMessage), array($errorCodeKey => $errorCode, $errorMessageKey => $errorMessage)); $objArray = array($taskBodyKey => $taskBody, $optionsKey => $options, $mediaProcessorIdKey => $mediaProcessorId, $errorKey => $error); $obj = Task::createFromOptions($objArray); $expected = ' <meta:properties xmlns:meta="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <data:' . $taskBodyKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $taskBody . '</data:' . $taskBodyKey . '> <data:' . $mediaProcessorIdKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $mediaProcessorId . '</data:' . $mediaProcessorIdKey . '> <data:' . $errorKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices"> <data:element xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices"> <data:' . $errorMessageKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorMessage . '</data:' . $errorMessageKey . '> <data:' . $errorCodeKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorCode . '</data:' . $errorCodeKey . '> </data:element> <data:element xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices"> <data:' . $errorMessageKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorMessage . '</data:' . $errorMessageKey . '> <data:' . $errorCodeKey . ' xmlns:data="http://schemas.microsoft.com/ado/2007/08/dataservices">' . $errorCode . '</data:' . $errorCodeKey . '> </data:element> </data:' . $errorKey . '> </meta:properties> '; // Test $result = ContentPropertiesSerializer::serialize($obj); // Assert $this->assertXmlStringEqualsXmlString($expected, $result); }
/** * Wraps media services entity with Atom entry * * @param object $entity Media services entity * @param array $links AtomLinks to other media services entities * * @return XML string representing Atom Entry */ protected function wrapAtomEntry($entity, $links = null) { Validate::notNull($entity, 'entity'); $content = new Content(); $content->setType(Resources::XML_CONTENT_TYPE); $content->setText(ContentPropertiesSerializer::serialize($entity)); $atomEntry = new Entry(); $atomEntry->setContent($content); if ($links) { Validate::isArray($links, 'links'); $atomEntry->setLink($links); } $xmlWriter = new \XMLWriter(); $xmlWriter->openMemory(); $atomEntry->writeXml($xmlWriter); return $xmlWriter->outputMemory(); }