You are here

public function FeedsSchedulerTestCase::testNextImportTimeWhenQueuedViaJobScheduler in Feeds 7.2

Tests if the expected next import time is shown when the import is queued via Job Scheduler.

File

tests/feeds_scheduler.test, line 286
Feeds tests.

Class

FeedsSchedulerTestCase
Test cron scheduling.

Code

public function testNextImportTimeWhenQueuedViaJobScheduler() {
  $this
    ->initSyndication();
  $this
    ->drupalLogin($this->admin_user);

  // Manually dispatch a job.
  $job = db_select('job_schedule', NULL, array(
    'fetch' => PDO::FETCH_ASSOC,
  ))
    ->fields('job_schedule')
    ->condition('type', 'syndication')
    ->condition('id', 18)
    ->execute()
    ->fetch();
  try {
    JobScheduler::get($job['name'])
      ->dispatch($job);
    $this
      ->pass('No exceptions occurred while dispatching a feeds job.');
  } catch (Exception $e) {
    watchdog_exception('feeds', $e);
    $this
      ->fail('No exceptions occurred while dispatching a feeds job.');
  }

  // 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
    ->drupalGet('node/18/import');
  $this
    ->assertText('Next import: on next cron run');
}