function CronRunTest::testCronRun
Tests cron runs.
File
-
core/
modules/ system/ tests/ src/ Functional/ System/ CronRunTest.php, line 36
Class
- CronRunTest
- Tests cron runs.
Namespace
Drupal\Tests\system\Functional\SystemCode
public function testCronRun() {
// Run cron anonymously without any cron key.
$this->drupalGet('cron');
$this->assertSession()
->statusCodeEquals(404);
// Run cron anonymously with a random cron key.
$key = $this->randomMachineName(16);
$this->drupalGet('cron/' . $key);
$this->assertSession()
->statusCodeEquals(403);
// Run cron anonymously with the valid cron key.
$key = \Drupal::state()->get('system.cron_key');
$this->drupalGet('cron/' . $key);
$this->assertSession()
->statusCodeEquals(204);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.