feeds_parser_syndication.test 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @file
  4. * Tests for plugins/FeedsSyndicationParser.inc.
  5. */
  6. /**
  7. * Test single feeds.
  8. */
  9. class FeedsSyndicationParserTestCase extends FeedsWebTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Syndication parsers',
  13. 'description' => 'Regression tests for syndication parsers Common syndication and SimplePie. Tests parsers against a set of feeds in the context of Feeds module. <strong>Requires SimplePie parser to be configured correctly.</strong>',
  14. 'group' => 'Feeds',
  15. );
  16. }
  17. /**
  18. * Run tests.
  19. */
  20. public function test() {
  21. // Only download simplepie if the plugin doesn't already exist somewhere.
  22. // People running tests locally might have it.
  23. if (!feeds_simplepie_exists()) {
  24. $this->downloadExtractSimplePie('1.3');
  25. $this->assertTrue(feeds_simplepie_exists());
  26. // Reset all the caches!
  27. $this->resetAll();
  28. }
  29. $this->createImporterConfiguration('Syndication', 'syndication');
  30. foreach (array('FeedsSyndicationParser', 'FeedsSimplePieParser') as $parser) {
  31. $this->setPlugin('syndication', $parser);
  32. foreach ($this->feedUrls() as $url => $assertions) {
  33. $this->createFeedNode('syndication', $url);
  34. $this->assertText('Created ' . $assertions['item_count'] . ' nodes');
  35. }
  36. }
  37. feeds_include_simplepie();
  38. variable_set('feeds_never_use_curl', TRUE);
  39. $link = $GLOBALS['base_url'] . '/testing/feeds/flickr.xml';
  40. $enclosure = new FeedsSimplePieEnclosure(new SimplePie_Enclosure($link));
  41. $enclosure->setAllowedExtensions('xml');
  42. $this->assertEqual(1, $enclosure->getFile('public://')->fid);
  43. }
  44. /**
  45. * Return an array of test feeds.
  46. */
  47. protected function feedUrls() {
  48. $path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/';
  49. return array(
  50. "{$path}developmentseed.rss2" => array(
  51. 'item_count' => 10,
  52. ),
  53. "{$path}feed_without_guid.rss2" => array(
  54. 'item_count' => 10,
  55. ),
  56. );
  57. }
  58. }