function AutomatedCronTest::testRunsCronOnHttpRequest
Same name and namespace in other branches
- 11.x core/modules/automated_cron/tests/src/Functional/AutomatedCronTest.php \Drupal\Tests\automated_cron\Functional\AutomatedCronTest::testRunsCronOnHttpRequest()
Tests that automated cron runs cron on an HTTP request.
File
-
core/
modules/ automated_cron/ tests/ src/ Functional/ AutomatedCronTest.php, line 32
Class
- AutomatedCronTest
- Tests for automated_cron.
Namespace
Drupal\Tests\automated_cron\FunctionalCode
public function testRunsCronOnHttpRequest() : void {
// Install cron manually to avoid test setup making an HTTP request which
// would trigger cron to run before the test starts.
\Drupal::service('module_installer')->install([
'automated_cron',
]);
// Set automated_cron interval and times.
// Any interval > 0 should work.
$this->config('automated_cron.settings')
->set('interval', 10800)
->save();
$this->assertNull(\Drupal::state()->get('system.cron_last'));
$this->assertNotNull($_SERVER['REQUEST_TIME']);
$this->setWaitForTerminate();
$this->drupalGet('/user/login');
$this->assertGreaterThanOrEqual($_SERVER['REQUEST_TIME'], \Drupal::state()->get('system.cron_last'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.