'Syndication parsers', 'description' => 'Regression tests for syndication parsers Common syndication and SimplePie. Tests parsers against a set of feeds in the context of Feeds module. Requires SimplePie parser to be configured correctly.', 'group' => 'Feeds', ); } /** * Run tests. */ public function test() { // Only download simplepie if the plugin doesn't already exist somewhere. // People running tests locally might have it. if (!feeds_simplepie_exists()) { $this->downloadExtractSimplePie('1.3'); $this->assertTrue(feeds_simplepie_exists()); // Reset all the caches! $this->resetAll(); } $this->createImporterConfiguration('Syndication', 'syndication'); foreach (array('FeedsSyndicationParser', 'FeedsSimplePieParser') as $parser) { $this->setPlugin('syndication', $parser); foreach ($this->feedUrls() as $url => $assertions) { $this->createFeedNode('syndication', $url); $this->assertText('Created ' . $assertions['item_count'] . ' nodes'); } } feeds_include_simplepie(); variable_set('feeds_never_use_curl', TRUE); $link = $GLOBALS['base_url'] . '/testing/feeds/flickr.xml'; $enclosure = new FeedsSimplePieEnclosure(new SimplePie_Enclosure($link)); $enclosure->setAllowedExtensions('xml'); $this->assertEqual(1, $enclosure->getFile('public://')->fid); } /** * Return an array of test feeds. */ protected function feedUrls() { $path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/'; return array( "{$path}developmentseed.rss2" => array( 'item_count' => 10, ), "{$path}feed_without_guid.rss2" => array( 'item_count' => 10, ), ); } }