You are here

public function FeedsSchedulerTestCase::testNextImportTimeWhenQueuedViaBackgroundJob in Feeds 7.2

Tests if the expected next import time is shown when the import is queued via background job.

File

tests/feeds_scheduler.test, line 250
Feeds tests.

Class

FeedsSchedulerTestCase
Test cron scheduling.

Code

public function testNextImportTimeWhenQueuedViaBackgroundJob() {

  // Create an importer that uses a background job to import.
  $this
    ->createImporterConfiguration('Node import', 'node');
  $edit = array(
    'content_type' => '',
    'import_on_create' => TRUE,
    'process_in_background' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/feeds/node/settings', $edit, 'Save');
  $this
    ->setPlugin('node', 'FeedsFileFetcher');
  $this
    ->setPlugin('node', 'FeedsCSVParser');
  $mappings = array(
    0 => array(
      'source' => 'title',
      'target' => 'title',
    ),
  );
  $this
    ->addMappings('node', $mappings);

  // Specify a file with many nodes.
  $this
    ->importFile('node', $this
    ->absolutePath() . '/tests/feeds/many_nodes.csv', 'Schedule import');

  // Verify that a queue item is created.
  $count = db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_import'")
    ->fetchField();
  $this
    ->assertEqual(1, $count, format_string('One import item is queued (actual: @count).', array(
    '@count' => $count,
  )));

  // The page should say that import happens on next cron.
  $this
    ->assertText('Next import: on next cron run');
}