You are here

feeds_parser_syndication.test in Feeds 7

Tests for plugins/FeedsSyndicationParser.inc.

File

tests/feeds_parser_syndication.test
View source
<?php

/**
 * @file
 * Tests for plugins/FeedsSyndicationParser.inc.
 */

// Require FeedsWebTestCase class definition.
require_once dirname(__FILE__) . '/feeds.test.inc';

/**
 * Test single feeds.
 */
class FeedsSyndicationParserTestCase extends FeedsWebTestCase {

  /**
   * Describe this test.
   */
  public function getInfo() {
    return array(
      'name' => t('Syndication parsers'),
      'description' => t('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>'),
      'group' => t('Feeds'),
    );
  }

  /**
   * Set up test.
   */
  public function setUp() {
    parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'libraries');
    $this
      ->drupalLogin($this
      ->drupalCreateUser(array(
      'administer feeds',
      'administer nodes',
    )));
  }

  /**
   * Run tests.
   */
  public function test() {
    $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'] . ' Article nodes.');
      }
    }
  }

  /**
   * 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,
      ),
    );
  }

}

Classes

Namesort descending Description
FeedsSyndicationParserTestCase Test single feeds.