예제 #1
0
 /**
  * Populates the properties with a the response from the list topics request.
  * 
  * @param string $response The body of the response of the list topics request. 
  * 
  * @return none
  */
 public function parseXml($response)
 {
     parent::parseXml($response);
     $listTopicsResultXml = new \SimpleXMLElement($response);
     $this->_topicInfos = array();
     foreach ($listTopicsResultXml->entry as $entry) {
         $topicInfo = new TopicInfo();
         $topicInfo->parseXml($entry->asXml());
         $this->_topicInfos[] = $topicInfo;
     }
 }
예제 #2
0
 /**
  * Populates the properties with the response from the list 
  * subscriptions request.
  * 
  * @param string $response The body of the response of the list 
  * subscriptions request. 
  * 
  * @return none
  */
 public function parseXml($response)
 {
     parent::parseXml($response);
     $listSubscriptionsResultXml = new \SimpleXMLElement($response);
     $this->_subscriptionInfos = array();
     foreach ($listSubscriptionsResultXml->entry as $entry) {
         $subscriptionInfo = new SubscriptionInfo();
         $subscriptionInfo->parseXml($entry->asXml());
         $this->_subscriptionInfos[] = $subscriptionInfo;
     }
 }
 /** 
  * @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);
 }
 /**
  * Get array of properties of atom entites passed via feed or single entry
  *
  * @param string $xmlString Atom xml
  *
  * @return array of properties arrays
  */
 protected function getEntryList($xmlString)
 {
     $xml = simplexml_load_string($xmlString);
     if ($xml->getName() == Resources::ENTRY) {
         $entry = new Entry();
         $entry->fromXml($xml);
         $entries = array($entry);
     } else {
         $feed = new Feed();
         $feed->parseXml($xmlString);
         $entries = $feed->getEntry();
     }
     $result = array();
     if (is_array($entries)) {
         foreach ($entries as $entry) {
             $properties = $this->getPropertiesFromAtomEntry($entry);
             if (!empty($properties)) {
                 $result[] = $properties;
             }
         }
     }
     return $result;
 }