\Drupal\Tests\datetime\Kernel\Views\FilterDateTest::testDateOffsets can fail during DST changes

Created on 8 April 2019, over 5 years ago
Updated 3 April 2023, over 1 year ago

Problem/Motivation

\Drupal\Tests\datetime\Kernel\Views\FilterDateTest::testDateOffsets() can randomly fail. See

1) Drupal\Tests\datetime_range\Kernel\Views\FilterDateTest::testDateOffsets
Actual result 
array (
  0 => 
  array (
    'nid' => '2',
  ),
)
 is  identical to expected 
array (
  0 => 
  array (
    'nid' => '1',
  ),
  1 => 
  array (
    'nid' => '2',
  ),
)

Failed asserting that Array &0 (
    0 => Array &1 (
        'nid' => '2'
    )
) is identical to Array &0 (
    0 => Array &1 (
        'nid' => '1'
    )
    1 => Array &2 (
        'nid' => '2'
    )
).

/var/www/html/core/tests/Drupal/KernelTests/AssertLegacyTrait.php:81
/var/www/html/core/modules/views/src/Tests/ViewResultAssertionTrait.php:146
/var/www/html/core/modules/views/src/Tests/ViewResultAssertionTrait.php:34
/var/www/html/core/modules/datetime_range/tests/src/Kernel/Views/FilterDateTest.php:136

The tests reported as running

00:05:35.953 Drupal test run
00:05:35.953 ---------------
00:05:35.953 
00:05:35.953 All tests will run.
00:05:35.953 
00:05:35.953 Test run started:
00:05:35.953   Sunday, April 7, 2019 - 13:44
00:05:35.953 
00:05:35.953 Test summary
00:05:35.954 ------------

As the time might be significant.

Proposed resolution

Change the test to user data providers so we can know which timezone has a problem. And try and work why this occurred.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

10.1

Component
Datetime 

Last updated 6 days ago

Created by

🇬🇧United Kingdom alexpott 🇪🇺🌍

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇦🇺Australia acbramley

    This happened again today with NZDT and AEDT transitioning back to standard time https://www.drupal.org/pift-ci-job/2633173

  • Status changed to Needs review over 1 year ago
  • 🇦🇺Australia acbramley

    I think this is caused by a bug in getUTCEquivalentOfUserNowAsTimestamp

    At the moment it gets "now" based on the user's current timezone and then formats that into a date object as UTC. This seems to be a bug since this would give the incorrect day as UTC if the test runs before 9/10 am (depending on DST). Because "now at 9am" in AEST is actually yesterday 11pm UTC.

    Swapping to simply set the timezone instead of constructing a new date seems like it should fix it, however I was unable to reproduce the failure locally.

  • Status changed to Needs work over 1 year ago
  • 🇦🇺Australia acbramley

    Hmm don't think that's going to work, manually testing by replacing "now" with "today 6am" fails as well.

Production build 0.71.5 2024