diff --git a/core/modules/system/tests/src/Functional/System/CronRunTest.php b/core/modules/system/tests/src/Functional/System/CronRunTest.php index 47ed4f788cbb2d515dc9cfc467a88e70f5d08a87..2eb5530212437f0cfece8de04f5bcd789e14b5d3 100644 --- a/core/modules/system/tests/src/Functional/System/CronRunTest.php +++ b/core/modules/system/tests/src/Functional/System/CronRunTest.php @@ -118,6 +118,11 @@ public function testCronExceptions(): void { * Make sure the cron UI reads from the state storage. */ public function testCronUI(): void { + // To prevent race conditions between the admin_user login triggering cron + // and updating its state, and this test doing the same thing, we use + // \Drupal\Tests\WaitTerminateTestTrait::setWaitForTerminate(). + $this->setWaitForTerminate(); + $admin_user = $this->drupalCreateUser(['administer site configuration']); $this->drupalLogin($admin_user); \Drupal::state()->delete('system.cron_last');