You are here

function CronRunTest::testCronRun in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/System/CronRunTest.php \Drupal\system\Tests\System\CronRunTest::testCronRun()

Test cron runs.

File

core/modules/system/src/Tests/System/CronRunTest.php, line 29
Contains \Drupal\system\Tests\System\CronRunTest.

Class

CronRunTest
Tests cron runs.

Namespace

Drupal\system\Tests\System

Code

function testCronRun() {

  // Run cron anonymously without any cron key.
  $this
    ->drupalGet('cron');
  $this
    ->assertResponse(404);

  // Run cron anonymously with a random cron key.
  $key = $this
    ->randomMachineName(16);
  $this
    ->drupalGet('cron/' . $key);
  $this
    ->assertResponse(403);

  // Run cron anonymously with the valid cron key.
  $key = \Drupal::state()
    ->get('system.cron_key');
  $this
    ->drupalGet('cron/' . $key);
  $this
    ->assertResponse(204);
}