You are here

public function FeedsExamplesFeedTestCase::test in Feeds 7

Same name and namespace in other branches
  1. 8.2 feeds_news/feeds_news.test \FeedsExamplesFeedTestCase::test()
  2. 6 feeds_news/feeds_news.test \FeedsExamplesFeedTestCase::test()
  3. 7.2 feeds_news/feeds_news.test \FeedsExamplesFeedTestCase::test()

Run tests.

File

feeds_news/feeds_news.test, line 45
Tests for feeds_news feature.

Class

FeedsExamplesFeedTestCase
Test Feed configuration.

Code

public function test() {
  $nid = $this
    ->createFeedNode('feed', NULL, '', 'feed');

  // Assert results.
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
  $this
    ->assertEqual($count, 10, 'Found the correct number of feed item nodes in database.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
  $this
    ->assertEqual($count, 10, 'Found the correct number of records in feeds_node_item.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Open Atrium Translation Workflow: Two Way Translation Updates'"));
  $this
    ->assertEqual($count, 1, 'Found title.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Week in DC Tech: October 5th Edition'"));
  $this
    ->assertEqual($count, 1, 'Found title.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Integrating the Siteminder Access System in an Open Atrium-based Intranet'"));
  $this
    ->assertEqual($count, 1, 'Found title.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE title = 'Scaling the Open Atrium UI'"));
  $this
    ->assertEqual($count, 1, 'Found title.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE url = 'http://developmentseed.org/blog/2009/oct/06/open-atrium-translation-workflow-two-way-updating'"));
  $this
    ->assertEqual($count, 1, 'Found feed_node_item record.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE url = 'http://developmentseed.org/blog/2009/oct/05/week-dc-tech-october-5th-edition'"));
  $this
    ->assertEqual($count, 1, 'Found feed_node_item record.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE guid = '974 at http://developmentseed.org'"));
  $this
    ->assertEqual($count, 1, 'Found feed_node_item record.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} WHERE guid = '970 at http://developmentseed.org'"));
  $this
    ->assertEqual($count, 1, 'Found feed_node_item record.');

  // Remove all items
  $this
    ->drupalPost('node/' . $nid . '/delete-items', array(), 'Delete');
  $this
    ->assertText('Deleted 10 nodes.');

  // Import again.
  $this
    ->drupalPost('node/' . $nid . '/import', array(), 'Import');
  $this
    ->assertText('Created 10 Feed item nodes.');

  // Delete and assert all items gone.
  $this
    ->drupalPost('node/' . $nid . '/delete-items', array(), 'Delete');
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
  $this
    ->assertEqual($count, 0, 'Found the correct number of feed item nodes in database.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
  $this
    ->assertEqual($count, 0, 'Found the correct number of records in feeds_node_item.');

  // Create a batch of nodes.
  $this
    ->createFeedNodes('feed', 10, 'feed');
  $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = 'feed_item'"));
  $this
    ->assertEqual($count, 100, 'Imported 100 nodes.');
  $count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
  $this
    ->assertEqual($count, 100, 'Found 100 records in feeds_node_item.');
}