You are here

public function FeedsSchedulerTestCase::testRescheduling in Feeds 7.2

Test if existing feed nodes get rescheduled upon save.

File

tests/feeds_scheduler.test, line 178
Feeds tests.

Class

FeedsSchedulerTestCase
Test cron scheduling.

Code

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

  // Configure to import as often as possible.
  $this
    ->setSettings('syndication', NULL, array(
    'import_period' => 0,
  ));

  // Remove all jobs to simulate the situation that no feed nodes are
  // scheduled.
  db_truncate('job_schedule')
    ->execute();

  // Also prevent feeds from rescheduling by itself as the import_period
  // setting was changed.
  variable_del('feeds_reschedule');

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

  // Assert that no nodes were created yet.
  $count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'article'")
    ->fetchField();
  $this
    ->assertEqual(0, $count, format_string('There are no articles yet (actual: @count).', array(
    '@count' => $count,
  )));

  // Now reschedule the first feed node by resaving the node.
  $this
    ->drupalPost('node/1/edit', array(), t('Save'));

  // And run cron again.
  $this
    ->cronRun();

  // Assert that 10 articles were created.
  $count = db_query("SELECT COUNT(*) FROM {node} WHERE type = 'article'")
    ->fetchField();
  $this
    ->assertEqual(10, $count, format_string('10 articles have been created (actual: @count).', array(
    '@count' => $count,
  )));
}