Ejemplo n.º 1
0
 /**
  * Creates an ATOM ENTRY instance with specified simpleXML object
  *
  * @param \SimpleXMLElement $entryXml xml element of ATOM ENTRY
  *
  * @return none
  */
 public function fromXml($entryXml)
 {
     Validate::notNull($entryXml, 'entryXml');
     Validate::isA($entryXml, '\\SimpleXMLElement', 'entryXml');
     $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->fromXml($entryArray['content']);
         $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']);
     }
 }
Ejemplo n.º 2
0
 /**
  * @covers WindowsAzure\Common\Internal\Atom\Content::fromXml
  */
 public function testFromXml()
 {
     // Setup
     $testText = 'SomeName';
     $testKey = 'name';
     $innerText = '<test>test string</test>';
     $xmlString = "<content>{$innerText}</content>";
     $atomContent = new Content();
     $xml = simplexml_load_string($xmlString);
     // Test
     $atomContent->fromXml($xml);
     // Assert
     $this->assertEquals($innerText, $atomContent->getText());
     $this->assertEquals($xml, $atomContent->getXml());
 }