/**
  * @covers WindowsAzure\Common\Internal\Atom\Entry::getCategory
  * @covers WindowsAzure\Common\Internal\Atom\Entry::setCategory
  */
 public function testEntryGetSetCategory()
 {
     // Setup
     $expected = new Category();
     $expected->setTerm('testTerm');
     $entry = new Entry();
     // Test
     $entry->setCategory($expected);
     $actual = $entry->getCategory();
     // Assert
     $this->assertEquals($expected->getTerm(), $actual->getTerm());
 }
 /** 
  * @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);
 }
 /** 
  * @covers WindowsAzure\Common\Internal\Atom\Source::getCategory
  * @covers WindowsAzure\Common\Internal\Atom\Source::setCategory
  */
 public function testGetSetCategory()
 {
     // Setup
     $expected = array();
     $category = new Category();
     $category->setTerm('testTerm');
     $expected[] = $category;
     $source = new Source();
     // Test
     $source->setCategory($expected);
     $actual = $source->getCategory();
     // Assert
     $this->assertEquals($expected, $actual);
 }
 /**
  * @covers WindowsAzure\Common\Internal\Atom\Category::writeXml
  */
 public function testCategoryWriteXmlInvalidParameter()
 {
     // Setup
     $this->setExpectedException(get_class(new \InvalidArgumentException()));
     $category = new Category();
     // Test
     $category->writeXml(null);
     // Assert
 }
Esempio n. 5
0
 /**
  * Processes category node.
  *
  * @param array $xmlArray An array of simple xml elements.
  *
  * @return array
  */
 protected function processCategoryNode($xmlArray)
 {
     $category = array();
     $categoryItem = $xmlArray[Resources::CATEGORY];
     if (is_array($categoryItem)) {
         foreach ($xmlArray[Resources::CATEGORY] as $categoryXmlInstance) {
             $categoryInstance = new Category();
             $categoryInstance->parseXml($categoryXmlInstance->asXML());
             $category[] = $categoryInstance;
         }
     } else {
         $categoryInstance = new Category();
         $categoryInstance->parseXml($categoryItem->asXML());
         $category[] = $categoryInstance;
     }
     return $category;
 }