You are here

public function FeedsSchedulerTestCase::testCleanUpJobsForNonExistingFeeds in Feeds 7.2

Tests if jobs are removed for feeds sources that no longer exist.

File

tests/feeds_scheduler.test, line 389
Feeds tests.

Class

FeedsSchedulerTestCase
Test cron scheduling.

Code

public function testCleanUpJobsForNonExistingFeeds() {

  // Create a fake job.
  $job = array(
    'type' => 'non_existing_importer',
    'id' => 12,
    'period' => 0,
    'periodic' => TRUE,
  );
  JobScheduler::get('feeds_source_import')
    ->set($job);

  // Assert that a job exist.
  $count = db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = 'non_existing_importer'")
    ->fetchField();
  $this
    ->assertEqual(1, $count, 'The fake job was created.');

  // Run cron.
  $this
    ->cronRun();

  // Assert that the job has been cleaned up.
  $count = db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = 'non_existing_importer'")
    ->fetchField();
  $this
    ->assertEqual(0, $count, 'The fake job no longer exists.');
}