public function CronRunTest::testCronRun in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Functional/System/CronRunTest.php \Drupal\Tests\system\Functional\System\CronRunTest::testCronRun()
- 10 core/modules/system/tests/src/Functional/System/CronRunTest.php \Drupal\Tests\system\Functional\System\CronRunTest::testCronRun()
Test 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);
}