Ejemplo n.º 1
0
 /** 
  * @covers WindowsAzure\Common\Internal\Atom\Generator::getText
  * @covers WindowsAzure\Common\Internal\Atom\Generator::setText
  */
 public function testGetSetText()
 {
     // Setup
     $expected = 'testText';
     $generator = new Generator();
     // Test
     $generator->setText($expected);
     $actual = $generator->getText();
     // Assert
     $this->assertEquals($expected, $actual);
 }
Ejemplo n.º 2
0
 /**
  * Creates a feed object with specified XML string. 
  *
  * @param string $xmlString An XML string representing the feed object.
  *
  * @return none
  */
 public function parseXml($xmlString)
 {
     $feedXml = simplexml_load_string($xmlString);
     $attributes = $feedXml->attributes();
     $feedArray = (array) $feedXml;
     if (!empty($attributes)) {
         $this->attributes = (array) $attributes;
     }
     if (array_key_exists('author', $feedArray)) {
         $this->author = $this->processAuthorNode($feedArray);
     }
     if (array_key_exists('entry', $feedArray)) {
         $this->entry = $this->processEntryNode($feedArray);
     }
     if (array_key_exists('category', $feedArray)) {
         $this->category = $this->processCategoryNode($feedArray);
     }
     if (array_key_exists('contributor', $feedArray)) {
         $this->contributor = $this->processContributorNode($feedArray);
     }
     if (array_key_exists('generator', $feedArray)) {
         $generator = new Generator();
         $generatorValue = $feedArray['generator'];
         if (is_string($generatorValue)) {
             $generator->setText($generatorValue);
         } else {
             $generator->parseXml($generatorValue->asXML());
         }
         $this->generator = $generator;
     }
     if (array_key_exists('icon', $feedArray)) {
         $this->icon = (string) $feedArray['icon'];
     }
     if (array_key_exists('id', $feedArray)) {
         $this->id = (string) $feedArray['id'];
     }
     if (array_key_exists('link', $feedArray)) {
         $this->link = $this->processLinkNode($feedArray);
     }
     if (array_key_exists('logo', $feedArray)) {
         $this->logo = (string) $feedArray['logo'];
     }
     if (array_key_exists('rights', $feedArray)) {
         $this->rights = (string) $feedArray['rights'];
     }
     if (array_key_exists('subtitle', $feedArray)) {
         $this->subtitle = (string) $feedArray['subtitle'];
     }
     if (array_key_exists('title', $feedArray)) {
         $this->title = (string) $feedArray['title'];
     }
     if (array_key_exists('updated', $feedArray)) {
         $this->updated = \DateTime::createFromFormat(\DateTime::ATOM, (string) $feedArray['updated']);
     }
 }
 /** 
  * @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);
 }
Ejemplo n.º 4
0
 /**
  * Creates a source object with specified XML string. 
  * 
  * @param string $xmlString The XML string representing a source.
  *
  * @return none
  */
 public function parseXml($xmlString)
 {
     $sourceXml = new \SimpleXMLElement($xmlString);
     $attributes = $sourceXml->attributes();
     $sourceArray = (array) $sourceXml;
     if (array_key_exists(Resources::AUTHOR, $sourceArray)) {
         $this->content = $this->processAuthorNode($sourceArray);
     }
     if (array_key_exists(Resources::CATEGORY, $sourceArray)) {
         $this->category = $this->processCategoryNode($sourceArray);
     }
     if (array_key_exists(Resources::CONTRIBUTOR, $sourceArray)) {
         $this->contributor = $this->processContributorNode($sourceArray);
     }
     if (array_key_exists('generator', $sourceArray)) {
         $generator = new Generator();
         $generator->setText((string) $sourceArray['generator']->asXML());
         $this->generator = $generator;
     }
     if (array_key_exists('icon', $sourceArray)) {
         $this->icon = (string) $sourceArray['icon'];
     }
     if (array_key_exists('id', $sourceArray)) {
         $this->id = (string) $sourceArray['id'];
     }
     if (array_key_exists(Resources::LINK, $sourceArray)) {
         $this->link = $this->processLinkNode($sourceArray);
     }
     if (array_key_exists('logo', $sourceArray)) {
         $this->logo = (string) $sourceArray['logo'];
     }
     if (array_key_exists('rights', $sourceArray)) {
         $this->rights = (string) $sourceArray['rights'];
     }
     if (array_key_exists('subtitle', $sourceArray)) {
         $this->subtitle = (string) $sourceArray['subtitle'];
     }
     if (array_key_exists('title', $sourceArray)) {
         $this->title = (string) $sourceArray['title'];
     }
     if (array_key_exists('updated', $sourceArray)) {
         $this->updated = \DateTime::createFromFormat(\DateTime::ATOM, (string) $sourceArray['updated']);
     }
 }