From 0880f31cbe1deef689ecaf56c4e437de7f6587ac Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 24 Mar 2015 14:38:29 +0000 Subject: [PATCH] Issue #2458289 by Wim Leers: CronRunTest::testAutomaticCron() should test with an authenticated user --- core/modules/system/src/Tests/System/CronRunTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/modules/system/src/Tests/System/CronRunTest.php b/core/modules/system/src/Tests/System/CronRunTest.php index de8cdcccbd7..e17bbf31129 100644 --- a/core/modules/system/src/Tests/System/CronRunTest.php +++ b/core/modules/system/src/Tests/System/CronRunTest.php @@ -49,6 +49,12 @@ class CronRunTest extends WebTestBase { * need the exact time when cron is triggered. */ function testAutomaticCron() { + // Test with a logged in user; anonymous users likely don't cause Drupal to + // fully bootstrap, because of the internal page cache or an external + // reverse proxy. Reuse this user for disabling cron later in the test. + $admin_user = $this->drupalCreateUser(array('administer site configuration')); + $this->drupalLogin($admin_user); + // Ensure cron does not run when the cron threshold is enabled and was // not passed. $cron_last = time(); @@ -68,8 +74,6 @@ class CronRunTest extends WebTestBase { $this->assertTrue($cron_last < \Drupal::state()->get('system.cron_last'), 'Cron runs when the cron threshold is passed.'); // Disable the cron threshold through the interface. - $admin_user = $this->drupalCreateUser(array('administer site configuration')); - $this->drupalLogin($admin_user); $this->drupalPostForm('admin/config/system/cron', array('cron_safe_threshold' => 0), t('Save configuration')); $this->assertText(t('The configuration options have been saved.')); $this->drupalLogout();