1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Tests for plugins/FeedsSyndicationParser.inc.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Test single feeds.
|
10
|
*/
|
11
|
class FeedsSyndicationParserTestCase extends FeedsWebTestCase {
|
12
|
|
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
|
);
|
19
|
}
|
20
|
|
21
|
/**
|
22
|
* Run tests.
|
23
|
*/
|
24
|
public function test() {
|
25
|
// Only download simplepie if the plugin doesn't already exist somewhere.
|
26
|
// People running tests locally might have it.
|
27
|
if (!feeds_simplepie_exists()) {
|
28
|
$this->downloadExtractSimplePie('1.3');
|
29
|
$this->assertTrue(feeds_simplepie_exists());
|
30
|
// Reset all the caches!
|
31
|
$this->resetAll();
|
32
|
}
|
33
|
|
34
|
$this->createImporterConfiguration('Syndication', 'syndication');
|
35
|
|
36
|
foreach (array('FeedsSyndicationParser', 'FeedsSimplePieParser') as $parser) {
|
37
|
$this->setPlugin('syndication', $parser);
|
38
|
foreach ($this->feedUrls() as $url => $assertions) {
|
39
|
$this->createFeedNode('syndication', $url);
|
40
|
$this->assertText('Created ' . $assertions['item_count'] . ' nodes');
|
41
|
}
|
42
|
}
|
43
|
|
44
|
feeds_include_simplepie();
|
45
|
variable_set('feeds_never_use_curl', TRUE);
|
46
|
|
47
|
$link = $GLOBALS['base_url'] . '/testing/feeds/flickr.xml';
|
48
|
$enclosure = new FeedsSimplePieEnclosure(new SimplePie_Enclosure($link));
|
49
|
|
50
|
$enclosure->setAllowedExtensions('xml');
|
51
|
$this->assertEqual(1, $enclosure->getFile('public://')->fid);
|
52
|
}
|
53
|
|
54
|
/**
|
55
|
* Return an array of test feeds.
|
56
|
*/
|
57
|
protected function feedUrls() {
|
58
|
$path = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/';
|
59
|
return array(
|
60
|
"{$path}developmentseed.rss2" => array(
|
61
|
'item_count' => 10,
|
62
|
),
|
63
|
"{$path}feed_without_guid.rss2" => array(
|
64
|
'item_count' => 10,
|
65
|
),
|
66
|
);
|
67
|
}
|
68
|
|
69
|
}
|