You are here

public function FeedsWebTestCase::importURL in Feeds 6

Same name and namespace in other branches
  1. 7.2 tests/feeds.test \FeedsWebTestCase::importURL()
  2. 7 tests/feeds.test.inc \FeedsWebTestCase::importURL()

Import a URL through the import form. Assumes FeedsHTTPFetcher in place.

1 call to FeedsWebTestCase::importURL()
FeedsRSStoNodesTest::test in tests/feeds_processor_node.test
Test node creation, refreshing/deleting feeds and feed items.

File

tests/feeds.test, line 264
Common functionality for all Feeds tests.

Class

FeedsWebTestCase
Test basic Data API functionality.

Code

public function importURL($id, $feed_url = NULL) {
  if (empty($feed_url)) {
    $feed_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2';
  }
  $edit = array(
    'feeds[FeedsHTTPFetcher][source]' => $feed_url,
  );
  $nid = $this
    ->drupalPost('import/' . $id, $edit, 'Import');

  // Check whether feed got recorded in feeds_source table.
  $this
    ->assertEqual(1, db_result(db_query("SELECT COUNT(*) FROM {feeds_source} WHERE id = '%s' AND feed_nid = 0", $id)));
  $source = db_fetch_object(db_query("SELECT * FROM {feeds_source} WHERE id = '%s' AND feed_nid = 0", $id));
  $config = unserialize($source->config);
  $this
    ->assertEqual($config['FeedsHTTPFetcher']['source'], $feed_url, t('URL in DB correct.'));

  // Check whether feed got properly added to scheduler.
  $this
    ->assertEqual(1, db_result(db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = '%s' AND id = 0 AND callback = 'feeds_source_import' AND last <> 0 AND scheduled = 0", $id)));

  // There must be only one entry for callback 'expire' - no matter what the feed_nid is.
  $this
    ->assertEqual(0, db_result(db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = '%s' AND callback = 'feeds_importer_expire' AND last <> 0 AND scheduled = 0", $id)));
}