Problem/Motivation

In bootstrap.php and WebTestBase::setUp() we try to ensure that the timezone for all tests is set to 'Australia/Sydney' because:

// Set the default timezone. While this doesn't cause any tests to fail, PHP
// complains if 'date.timezone' is not set in php.ini. The Australia/Sydney
// timezone is chosen so all tests are run using an edge case scenario (UTC+10
// and DST). This choice is made to prevent timezone related regressions and
// reduce the fragility of the testing system in general.

Tests extending \Drupal\simpletest\InstallerTestBase() use the interactive installer which results in sites being installer in whatever the default timezone the user has set in PHP.

Proposed resolution

Set the default timezone in installer when installing for a test.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Status: Active » Needs review
FileSize
712 bytes
1.69 KB

Here's a patch with a test - hopefully the testbots timezone is not Australia/Sydney cause if so the test only patch will pass. It fails locally as expected for my system where the default timezone is Europe/Zurich.

Fail      Other      InstallerTest.php   30 Drupal\system\Tests\Installer\Insta
    Value 'Europe/Zurich' is equal to value 'Australia/Sydney'.

The last submitted patch, 2: 2915664-2.test-only.patch, failed testing. View results

alexpott’s picture

Phew testbots have a timezone of UTC.
Value 'UTC' is equal to value 'Australia/Sydney'

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice finding!

I had a quick look whether there is more to sync up:

// Set sane locale settings, to ensure consistent string, dates, times and
// numbers handling.
// @see \Drupal\Core\DrupalKernel::bootEnvironment()
setlocale(LC_ALL, 'C');

but as the comment says, its already in the drupal kernel, which is used by the installer as well.

  • xjm committed e84da2f on 8.5.x
    Issue #2915664 by alexpott, dawehner: Sites installed by...

  • xjm committed d260101 on 8.4.x
    Issue #2915664 by alexpott, dawehner: Sites installed by...
xjm’s picture

Status: Reviewed & tested by the community » Fixed
Related issues: +#2825845: DST-related test failures in FilterDateTimeTest

I wonder if this will fix the semi-annual #2825845: DST-related test failures in FilterDateTimeTest, which happened again when Australia went to summer time?

Committed and pushed to 8.5.x and backported to 8.4.x. Thanks! Thanks also for #5; I would also have checked for something along those lines but not known where to check.

mpdonadio’s picture

I am really surprised this didn't cause more problems. I wonder if we are missing more test coverage somewhere?

alexpott’s picture

@mpdonadio this only affected tests extending from InstallerTestBase tests - ie. doing an interactive install. There are not too many of those tests and very few of them do anything test related. So unfortunately I don't think this is going to affect #2825845: DST-related test failures in FilterDateTimeTest because that's not an InstallerTestBase test.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.