Make WordPress Core

Opened 19 months ago

Closed 19 months ago

Last modified 19 months ago

#63079 closed defect (bug) (fixed)

Phpunit test failure due to US daylight saving time

Reported by: audrasjb Owned by: johnbillion
Priority: normal Milestone: 6.8
Component: Date/Time Version: 6.9
Severity: normal Keywords: has-patch has-unit-tests commit
Cc: Focuses:

Description

The test_wp_timezone_override_offset phpunit test is currently failing due to US daylight saving time.

Change History (11)

#1 @audrasjb
19 months ago

  • Component General → Build/Test Tools

#2 @audrasjb
19 months ago

Test failure:

Tests_Functions_wpTimezoneOverrideOffset::test_wp_timezone_override_offset with data set "NST option set" ('America/St_Johns', -3.5)
Failed asserting that -2.5 is identical to -3.5.

#3 @audrasjb
19 months ago

Related: #59980

Introduced in [59931].

This ticket was mentioned in ​PR #8479 on ​WordPress/wordpress-develop by ​@debarghyabanerjee.


19 months ago
#4

  • Keywords has-patch has-unit-tests added; needs-patch removed

Trac Ticke: Core-63079

### Summary

  • This PR fixes the failing test for wp_timezone_override_offset(), caused by Daylight Saving Time (DST) adjustments in America/St_Johns. The test previously expected a static -3.5 offset, but during DST, the actual offset is -2.5, leading to failures.

### Changes

  • Introduced get_expected_offset() to dynamically determine the correct offset.
  • Updated the test data provider to use this function instead of a hardcoded value.

​@audrasjb commented on ​PR #8479:


19 months ago
#5

I think a better approach would be something along the lines of: if the America/St_Johns timezone is currently observing DST then the expected value is -2.5, else the expected value is -3.5. What do you think?

Yes, nice idea, sounds good to me 👍

​@debarghyabanerjee commented on ​PR #8479:


19 months ago
#6

Hi @johnbillion , It makes sense, thanks for the review and feedback. I have updated the implementation, can you please check once. Assigning your for re-review.

This ticket was mentioned in ​Slack in #core by audrasjb. ​View the logs.


19 months ago

#8 @johnbillion
19 months ago

  • Component Build/Test Tools → Date/Time
  • Keywords commit added

#9 @johnbillion
19 months ago

  • Owner set to johnbillion
  • Resolution → fixed
  • Status new → closed

In 59959:

Date/Time: Fix the recently introduced test for wp_timezone_override_offset() which failed to take into consideration daylight saving time for the America/St_Johns timezone.

Props debarghyabanerjee, johnbillion, mukesh27, audrasjb.

Fixes #63079

​@johnbillion commented on ​PR #8479:


19 months ago
#10

This was committed in https://core.trac.wordpress.org/changeset/59959 . Thanks everyone!

​@johnbillion commented on ​PR #8479:


19 months ago
#11

This was committed in https://core.trac.wordpress.org/changeset/59959 . Thanks everyone!

Note: See TracTickets for help on using tickets.