class AutomatedCronTest
Same name in this branch
- main core/modules/automated_cron/tests/src/Kernel/AutomatedCronTest.php \Drupal\Tests\automated_cron\Kernel\AutomatedCronTest
Same name and namespace in other branches
- 11.x core/modules/automated_cron/tests/src/Kernel/AutomatedCronTest.php \Drupal\Tests\automated_cron\Kernel\AutomatedCronTest
- 11.x core/modules/automated_cron/tests/src/Functional/AutomatedCronTest.php \Drupal\Tests\automated_cron\Functional\AutomatedCronTest
Tests for automated_cron.
Attributes
#[Group('automated_cron')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\automated_cron\Functional\AutomatedCronTest uses \Drupal\Tests\WaitTerminateTestTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of AutomatedCronTest
File
-
core/
modules/ automated_cron/ tests/ src/ Functional/ AutomatedCronTest.php, line 15
Namespace
Drupal\Tests\automated_cron\FunctionalView source
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'));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.