You are here

public function FeedsWebTestCase::importURL in Feeds 7.2

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

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

2 calls to FeedsWebTestCase::importURL()
FeedsRSStoNodesTest::test in tests/feeds_processor_node.test
Test node creation, refreshing/deleting feeds and feed items.
FeedsRSStoNodesTest::testExpiry in tests/feeds_processor_node.test
Tests expiring nodes.

File

tests/feeds.test, line 347
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,
  ))
    ->fetchObject();
  $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 name = 'feeds_source_import' AND last <> 0 AND scheduled = 0", array(
    ':id' => $id,
  ))
    ->fetchField());

  // Check expire scheduler.
  if (feeds_importer($id)->processor
    ->expiryTime() == FEEDS_EXPIRE_NEVER) {
    $this
      ->assertEqual(0, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_expire'", array(
      ':id' => $id,
    ))
      ->fetchField());
  }
  else {
    $this
      ->assertEqual(1, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_expire'", array(
      ':id' => $id,
    ))
      ->fetchField());
  }
}