/** * @covers WindowsAzure\MediaServices\Internal\ContentPropertiesSerializer::unserialize * @covers WindowsAzure\MediaServices\Internal\ContentPropertiesSerializer::_unserializeRecursive */ public function testUnserializeCollection() { // Setup $testString = 'testString'; $nameKey = 'name'; $otherNameKey = 'name'; $objectKey = 'object'; $xmlString = '<properties xmlns="' . Resources::DSM_XML_NAMESPACE . '" xmlns:d="' . Resources::DS_XML_NAMESPACE . '"> <d:' . $nameKey . '>' . $testString . '</d:' . $nameKey . '> <d:' . $objectKey . '> <d:element> <d:' . $nameKey . '>' . $testString . '</d:' . $nameKey . '> </d:element> <d:element> <d:' . $otherNameKey . '>' . $testString . '</d:' . $otherNameKey . '> </d:element> </d:' . $objectKey . '> </properties>'; $xml = simplexml_load_string($xmlString); // Test $result = ContentPropertiesSerializer::unserialize($xml); // Assert $this->assertEquals(2, count($result)); $this->assertEquals($testString, $result[$nameKey]); $this->assertEquals(2, count($result[$objectKey])); $this->assertEquals(1, count($result[$objectKey][0])); $this->assertEquals($testString, $result[$objectKey][0][$nameKey]); $this->assertEquals(1, count($result[$objectKey][1])); $this->assertEquals($testString, $result[$objectKey][1][$otherNameKey]); }
/** * Extract media service entity from Atom Entry object * * @param WindowsAzure\Common\Internal\Atom\Entry $entry Atom Entry containing * properties of media services object * * @return array of properties name => value */ protected function getPropertiesFromAtomEntry($entry) { Validate::notNull($entry, 'entry'); Validate::isA($entry, 'WindowsAzure\\Common\\Internal\\Atom\\Entry', 'entry'); $result = array(); $content = $entry->getContent(); if (!empty($content)) { $result = ContentPropertiesSerializer::unserialize($content->getXml()->children(Resources::DSM_XML_NAMESPACE)); } return $result; }