You are here

public function FeedsWebTestCase::importURL in Feeds 7

Same name and namespace in other branches
  1. 6 tests/feeds.test \FeedsWebTestCase::importURL()
  2. 7.2 tests/feeds.test \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.inc, line 247
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_query("SELECT COUNT(*) FROM {feeds_source} WHERE id = :id AND feed_nid = 0", array(
    ':id' => $id,
  ))
    ->fetchField());
  $source = db_query("SELECT * FROM {feeds_source} WHERE id = :id AND feed_nid = 0", array(
    ':id' => $id,
  ))
    ->fetch();
  $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_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND callback = 'feeds_source_import' AND last <> 0 AND scheduled = 0", array(
    ':id' => $id,
  ))
    ->fetchField());

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