You are here

function CronRunTestCase::testCronRun in Drupal 7

Test cron runs.

File

modules/system/system.test, line 813
Tests for system.module.

Class

CronRunTestCase

Code

function testCronRun() {
  global $base_url;

  // Run cron anonymously without any cron key.
  $this
    ->drupalGet($base_url . '/cron.php', array(
    'external' => TRUE,
  ));
  $this
    ->assertResponse(403);

  // Run cron anonymously with a random cron key.
  $key = $this
    ->randomName(16);
  $this
    ->drupalGet($base_url . '/cron.php', array(
    'external' => TRUE,
    'query' => array(
      'cron_key' => $key,
    ),
  ));
  $this
    ->assertResponse(403);

  // Run cron anonymously with the valid cron key.
  $key = variable_get('cron_key', 'drupal');
  $this
    ->drupalGet($base_url . '/cron.php', array(
    'external' => TRUE,
    'query' => array(
      'cron_key' => $key,
    ),
  ));
  $this
    ->assertResponse(200);
}