function CronRunTest::testCronRun

Test cron runs.

File

drupal/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php, line 32
Definition of Drupal\system\Tests\System\CronRunTest.

Class

CronRunTest

Namespace

Drupal\system\Tests\System

Code

function testCronRun() {
  global $base_url;

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

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

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