feeds_parser_syndication.test 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. 'dependencies' => array('libraries'),
  16. );
  17. }
  18. /**
  19. * Set up test.
  20. */
  21. public function setUp() {
  22. parent::setUp(array('libraries'));
  23. }
  24. /**
  25. * Run tests.
  26. */
  27. public function test() {
  28. $this->createImporterConfiguration('Syndication', 'syndication');
  29. foreach (array('FeedsSyndicationParser', 'FeedsSimplePieParser') as $parser) {
  30. $this->setPlugin('syndication', $parser);
  31. foreach ($this->feedUrls() as $url => $assertions) {
  32. $this->createFeedNode('syndication', $url);
  33. $this->assertText('Created ' . $assertions['item_count'] . ' nodes');
  34. }
  35. }
  36. }
  37. /**
  38. * Return an array of test feeds.
  39. */
  40. protected function feedUrls() {
  41. $path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/';
  42. return array(
  43. "{$path}developmentseed.rss2" => array(
  44. 'item_count' => 10,
  45. ),
  46. "{$path}feed_without_guid.rss2" => array(
  47. 'item_count' => 10,
  48. ),
  49. );
  50. }
  51. }