1 | <?php |
---|
2 | module_load_include('test', 'feeds', 'tests/feeds'); |
---|
3 | |
---|
4 | /** |
---|
5 | * @file |
---|
6 | * Tests for plugins/FeedsSyndicationParser.inc. |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * Test single feeds. |
---|
11 | */ |
---|
12 | class FeedsSyndicationParserTestCase extends FeedsWebTestCase { |
---|
13 | public static function getInfo() { |
---|
14 | return array( |
---|
15 | 'name' => 'Syndication parsers', |
---|
16 | '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>', |
---|
17 | 'group' => 'Feeds', |
---|
18 | 'dependencies' => array('libraries'), |
---|
19 | ); |
---|
20 | } |
---|
21 | |
---|
22 | /** |
---|
23 | * Set up test. |
---|
24 | */ |
---|
25 | public function setUp() { |
---|
26 | parent::setUp(array('libraries')); |
---|
27 | } |
---|
28 | |
---|
29 | /** |
---|
30 | * Run tests. |
---|
31 | */ |
---|
32 | public function test() { |
---|
33 | $this->createImporterConfiguration('Syndication', 'syndication'); |
---|
34 | |
---|
35 | foreach (array('FeedsSyndicationParser', 'FeedsSimplePieParser') as $parser) { |
---|
36 | $this->setPlugin('syndication', $parser); |
---|
37 | foreach ($this->feedUrls() as $url => $assertions) { |
---|
38 | $this->createFeedNode('syndication', $url); |
---|
39 | $this->assertText('Created '. $assertions['item_count'] .' Story nodes.'); |
---|
40 | } |
---|
41 | } |
---|
42 | } |
---|
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 | } |
---|