示例#1
0
 /**
  * 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
  */
 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)) {
         $propertiesXml = $content->getXml()->children(Resources::DSM_XML_NAMESPACE);
         $properties = new ContentProperties();
         $properties->fromXml($propertiesXml);
         $result = $properties->getProperties();
     }
     return $result;
 }
 /**
  * @covers WindowsAzure\MediaServices\Models\ContentProperties::writeXml
  */
 public function testWriteXml()
 {
     // Setup
     $name = 'Name';
     $option = Asset::OPTIONS_NONE;
     $asset = new Asset($option);
     $asset->setName($name);
     $asset->setOptions(Asset::OPTIONS_STORAGE_ENCRYPTED);
     $prop = new ContentProperties();
     $prop->setPropertiesFromObject($asset);
     $properties = $prop->getProperties();
     // Test
     $xmlWriter = new \XMLWriter();
     $xmlWriter->openMemory();
     $prop->writeXml($xmlWriter);
     $actual = $xmlWriter->outputMemory();
     $xml = simplexml_load_string($actual);
     $childrenCount = 0;
     foreach ($xml->children(Resources::DS_XML_NAMESPACE) as $child) {
         // Assert
         $this->assertContains((string) $child, $properties);
         $childrenCount++;
     }
     // Assert
     $this->assertEquals(2, $childrenCount);
 }