/**
  * @covers WindowsAzure\Common\Internal\Atom\Content::getXml
  */
 public function testGetXml()
 {
     // Setup
     $xml = '<atom:content xmlns:atom="http://www.w3.org/2005/Atom"></atom:content>';
     $content = new Content();
     $content->parseXml($xml);
     // Test
     $result = $content->getXml();
     // Assert
     $this->assertNotNull($result);
     $this->assertInstanceOf('\\SimpleXMLElement', $result);
 }
示例#2
0
 /**
  * Populate the properties of an ATOM Entry instance with specified XML.. 
  * 
  * @param string $xmlString A string representing an ATOM entry instance. 
  * 
  * @return none
  */
 public function parseXml($xmlString)
 {
     Validate::notNull($xmlString, 'xmlString');
     $entryXml = simplexml_load_string($xmlString);
     $this->attributes = (array) $entryXml->attributes();
     $entryArray = (array) $entryXml;
     if (array_key_exists(Resources::AUTHOR, $entryArray)) {
         $this->author = $this->processAuthorNode($entryArray);
     }
     if (array_key_exists(Resources::CATEGORY, $entryArray)) {
         $this->category = $this->processCategoryNode($entryArray);
     }
     if (array_key_exists('content', $entryArray)) {
         $content = new Content();
         $content->parseXml($entryArray['content']->asXML());
         $this->content = $content;
     }
     if (array_key_exists(Resources::CONTRIBUTOR, $entryArray)) {
         $this->contributor = $this->processContributorNode($entryArray);
     }
     if (array_key_exists('id', $entryArray)) {
         $this->id = (string) $entryArray['id'];
     }
     if (array_key_exists(Resources::LINK, $entryArray)) {
         $this->link = $this->processLinkNode($entryArray);
     }
     if (array_key_exists('published', $entryArray)) {
         $this->published = $entryArray['published'];
     }
     if (array_key_exists('rights', $entryArray)) {
         $this->rights = $entryArray['rights'];
     }
     if (array_key_exists('source', $entryArray)) {
         $source = new Source();
         $source->parseXml($entryArray['source']->asXML());
         $this->source = $source;
     }
     if (array_key_exists('title', $entryArray)) {
         $this->title = $entryArray['title'];
     }
     if (array_key_exists('updated', $entryArray)) {
         $this->updated = \DateTime::createFromFormat(\DateTime::ATOM, (string) $entryArray['updated']);
     }
 }