/** * Method to handle the feed entry element for the feed: <item>. * * @param JFeedEntry $entry The JFeedEntry object being built from the parsed feed entry. * @param SimpleXMLElement $el The current XML element object to handle. * * @return void * * @since 12.3 */ protected function processFeedEntry(JFeedEntry $entry, SimpleXMLElement $el) { $entry->uri = (string) $el->link; $entry->title = (string) $el->title; $entry->publishedDate = (string) $el->pubDate; $entry->updatedDate = (string) $el->pubDate; $entry->content = (string) $el->description; $entry->guid = (string) $el->guid; $entry->comments = (string) $el->comments; // Add the feed entry author if available. $author = (string) $el->author; if (!empty($author)) { $entry->author = $this->processPerson($author); } // Add any categories to the entry. foreach ($el->category as $category) { $entry->addCategory((string) $category, (string) $category['domain']); } // Add any enclosures to the entry. foreach ($el->enclosure as $enclosure) { $link = new JFeedLink((string) $enclosure['url'], null, (string) $enclosure['type'], null, null, (int) $enclosure['length']); $entry->addLink($link); } }
/** * Tests the JFeedEntry::addCategory method. * * @return void * * @since 12.3 */ public function testAddCategory() { $this->_instance->addCategory('category1', 'http://www.example.com'); $properties = TestReflection::getValue($this->_instance, 'properties'); $this->assertEquals('http://www.example.com', $properties['categories']['category1']); }