示例#1
0
 /**
  * Tests the JFeed::addEntry method.
  *
  * @return  void
  *
  * @since   3.0
  *
  * @covers  JFeed::addEntry
  */
 public function testAddEntry()
 {
     $entry = new JFeedEntry();
     $this->object->addEntry($entry);
     $entries = TestReflection::getValue($this->object, 'entries');
     $this->assertEquals($entry, $entries[0]);
     $this->object->addEntry($entry);
     $entries = TestReflection::getValue($this->object, 'entries');
     // Make sure we aren't adding the same entry more than once.
     $this->assertTrue(count($entries) == 1);
 }
示例#2
0
文件: parser.php 项目: adjaika/J3Base
 /**
  * Method to parse a specific feed element.
  *
  * @param   JFeed             $feed        The JFeed object being built from the parsed feed.
  * @param   SimpleXMLElement  $el          The current XML element object to handle.
  * @param   array             $namespaces  The array of relevant namespace objects to process for the element.
  *
  * @return  void
  *
  * @since   12.3
  */
 protected function processElement(JFeed $feed, SimpleXMLElement $el, array $namespaces)
 {
     // Build the internal method name.
     $method = 'handle' . ucfirst($el->getName());
     // If we are dealing with an item then it is feed entry time.
     if ($el->getName() == $this->entryElementName) {
         // Create a new feed entry for the item.
         $entry = new JFeedEntry();
         // First call the internal method.
         $this->processFeedEntry($entry, $el);
         foreach ($namespaces as $namespace) {
             if ($namespace instanceof JFeedParserNamespace) {
                 $namespace->processElementForFeedEntry($entry, $el);
             }
         }
         // Add the new entry to the feed.
         $feed->addEntry($entry);
         return;
     }
     // Otherwise we treat it like any other element.
     // First call the internal method.
     if (is_callable(array($this, $method))) {
         $this->{$method}($feed, $el);
     }
     foreach ($namespaces as $namespace) {
         if ($namespace instanceof JFeedParserNamespace) {
             $namespace->processElementForFeed($feed, $el);
         }
     }
 }