AutomatedCronTest.php
Same filename in this branch
Same filename and directory in other branches
Namespace
Drupal\Tests\automated_cron\FunctionalFile
-
core/
modules/ automated_cron/ tests/ src/ Functional/ AutomatedCronTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\automated_cron\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\WaitTerminateTestTrait;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
/**
* Tests for automated_cron.
*/
class AutomatedCronTest extends BrowserTestBase {
use WaitTerminateTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'automated_cron',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests that automated cron runs cron on an HTTP request.
*
* @legacy-covers \Drupal\automated_cron\EventSubscriber\AutomatedCron::onTerminate
*/
public function testRunsCronOnHttpRequest() : void {
// Set automated_cron interval and times.
// Any interval > 0 should work.
$this->config('automated_cron.settings')
->set('interval', 10800)
->save();
\Drupal::state()->delete('system.cron_last');
$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'));
}
}
Classes
| Title | Deprecated | Summary |
|---|---|---|
| AutomatedCronTest | Tests for automated_cron. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.