summaryrefslogtreecommitdiffstatshomepage
path: root/modules/aggregator/aggregator.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/aggregator/aggregator.test')
-rw-r--r--modules/aggregator/aggregator.test54
1 files changed, 54 insertions, 0 deletions
diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test
index 93e77f98907f..b37c0f933564 100644
--- a/modules/aggregator/aggregator.test
+++ b/modules/aggregator/aggregator.test
@@ -248,6 +248,12 @@ EOF;
return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml';
}
+ function getAtomSample() {
+ // The content of this sample ATOM feed is based directly off of the
+ // example provided in RFC 4287.
+ return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_atom.xml';
+ }
+
function createSampleNodes() {
$langcode = LANGUAGE_NONE;
// Post 5 articles.
@@ -686,3 +692,51 @@ class AggregatorCronTestCase extends AggregatorTestCase {
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->fid))->fetchField(), 'Expected number of items in database.');
}
}
+
+/**
+ * Tests for feed parsing.
+ */
+class FeedParserTestCase extends AggregatorTestCase {
+ function getInfo() {
+ return array(
+ 'name' => 'Feed parser functionality',
+ 'description' => 'Test the built-in feed parser with valid feed samples.',
+ 'group' => 'Aggregator',
+ );
+ }
+
+ function setUp() {
+ parent::setUp();
+ // Do not remove old aggregator items during these tests, since our sample
+ // feeds have hardcoded dates in them (which may be expired when this test
+ // is run).
+ variable_set('aggregator_clear', AGGREGATOR_CLEAR_NEVER);
+ }
+
+ /**
+ * Test a feed that uses the RSS 0.91 format.
+ */
+ function testRSS091Sample() {
+ $feed = $this->createFeed($this->getRSS091Sample());
+ aggregator_refresh($feed);
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(200, t('Feed %name exists.', array('%name' => $feed->title)));
+ $this->assertText('First example feed item title');
+ $this->assertLinkByHref('http://example.com/example-turns-one');
+ $this->assertText('First example feed item description.');
+ }
+
+ /**
+ * Test a feed that uses the Atom format.
+ */
+ function testAtomSample() {
+ $feed = $this->createFeed($this->getAtomSample());
+ aggregator_refresh($feed);
+ $this->drupalGet('aggregator/sources/' . $feed->fid);
+ $this->assertResponse(200, t('Feed %name exists.', array('%name' => $feed->title)));
+ $this->assertText('Atom-Powered Robots Run Amok');
+ $this->assertLinkByHref('http://example.org/2003/12/13/atom03');
+ $this->assertText('Some text.');
+ }
+}
+