1.20.x system.test CronRunTestCase::testCronRun()

Test cron runs.

File

modules/system/tests/system.test, line 658
Tests for system.module.

Class

CronRunTestCase

Code

function testCronRun() {
  global $base_url;

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

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

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