Example #1
0
 /** 
  * Writes an XML representing the feed object.
  * 
  * @param \XMLWriter $xmlWriter The XML writer.
  * 
  * @return none
  */
 public function writeInnerXml($xmlWriter)
 {
     Validate::notNull($xmlWriter, 'xmlWriter');
     if (!is_null($this->attributes)) {
         if (is_array($this->attributes)) {
             foreach ($this->attributes as $attributeName => $attributeValue) {
                 $xmlWriter->writeAttribute($attributeName, $attributeValue);
             }
         }
     }
     if (!is_null($this->author)) {
         $this->writeArrayItem($xmlWriter, $this->author, Resources::AUTHOR);
     }
     if (!is_null($this->category)) {
         $this->writeArrayItem($xmlWriter, $this->category, Resources::CATEGORY);
     }
     if (!is_null($this->contributor)) {
         $this->writeArrayItem($xmlWriter, $this->contributor, Resources::CONTRIBUTOR);
     }
     if (!is_null($this->generator)) {
         $this->generator->writeXml($xmlWriter);
     }
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'icon', Resources::ATOM_NAMESPACE, $this->icon);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'logo', Resources::ATOM_NAMESPACE, $this->logo);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'id', Resources::ATOM_NAMESPACE, $this->id);
     if (!is_null($this->link)) {
         $this->writeArrayItem($xmlWriter, $this->link, Resources::LINK);
     }
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'rights', Resources::ATOM_NAMESPACE, $this->rights);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'subtitle', Resources::ATOM_NAMESPACE, $this->subtitle);
     $this->writeOptionalElementNS($xmlWriter, 'atom', 'title', Resources::ATOM_NAMESPACE, $this->title);
     if (!is_null($this->updated)) {
         $xmlWriter->writeElementNS('atom', 'updated', Resources::ATOM_NAMESPACE, $this->updated->format(\DateTime::ATOM));
     }
 }
 /** 
  * @covers WindowsAzure\Common\Internal\Atom\Generator::getVersion
  * @covers WindowsAzure\Common\Internal\Atom\Generator::setVersion
  */
 public function testGetSetVersion()
 {
     // Setup
     $expected = 'testVersion';
     $generator = new Generator();
     // Test
     $generator->setVersion($expected);
     $actual = $generator->getVersion();
     // Assert
     $this->assertEquals($expected, $actual);
 }
 /** 
  * @covers WindowsAzure\Common\Internal\Atom\Feed::parseXml
  */
 public function testFeedParseXmlAllProperties()
 {
     // Setup
     $expected = new Feed();
     $entry = array();
     $entry[] = new Entry();
     $category = array();
     $categoryInstance = new Category();
     $categoryInstance->setScheme('testCategory');
     $category[] = $categoryInstance;
     $contributor = array();
     $contributorItem = new Person();
     $contributorItem->setName('testContributor');
     $contributor[] = $contributorItem;
     $generator = new Generator();
     $generator->setText('testGenerator');
     $icon = 'testIcon';
     $id = 'testId';
     $link = array();
     $atomLink = new AtomLink();
     $atomLink->setHref('testLink');
     $link[] = $atomLink;
     $logo = 'testLogo';
     $rights = 'testRights';
     $subtitle = 'testSubtitle';
     $title = 'testTitle';
     $updated = \DateTime::createFromFormat(\DateTime::ATOM, '2011-09-29T23:50:26+00:00');
     $expected->setEntry($entry);
     $expected->setCategory($category);
     $expected->setContributor($contributor);
     $expected->setGenerator($generator);
     $expected->setIcon($icon);
     $expected->setId($id);
     $expected->setLink($link);
     $expected->setLogo($logo);
     $expected->setRights($rights);
     $expected->setSubtitle($subtitle);
     $expected->setTitle($title);
     $expected->setUpdated($updated);
     $actual = new Feed();
     $xml = '
     <feed xmlns="http://www.w3.org/2005/Atom">
         <entry/>
         <content/>
         <category scheme="testCategory"/>
         <contributor>testContributor</contributor>
         <generator>testGenerator</generator>
         <icon>testIcon</icon>
         <id>testId</id>
         <link href="testLink"/>
         <logo>testLogo</logo>
         <rights>testRights</rights>
         <subtitle>testSubtitle</subtitle>
         <title>testTitle</title>
         <updated>2011-09-29T23:50:26+00:00</updated>
     </feed>';
     // Test
     $actual->parseXml($xml);
     // Assert
     $this->assertEquals($expected, $actual);
 }