Changeset 54230 for trunk/tests/phpunit/tests/date/currentTime.php
- Timestamp:
- 09/19/2022 11:51:20 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/date/currentTime.php
r54217 r54230 129 129 $this->assertEqualsWithDelta( strtotime( $datetime_utc->format( DATE_W3C ) ), strtotime( current_time( DATE_W3C, true ) ), 2, 'The dates should be equal' ); 130 130 } 131 132 /** 133 * Ensures that deprecated timezone strings are handled correctly. 134 * 135 * @ticket 56468 136 */ 137 public function test_should_work_with_deprecated_timezone() { 138 $format = 'Y-m-d H:i'; 139 $timezone_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6. 140 update_option( 'timezone_string', $timezone_string ); 141 $datetime = new DateTime( 'now', new DateTimeZone( $timezone_string ) ); 142 143 // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set 144 date_default_timezone_set( $timezone_string ); 145 146 $current_time_custom_timezone_gmt = current_time( $format, true ); 147 $current_time_custom_timezone = current_time( $format ); 148 149 // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set 150 date_default_timezone_set( 'UTC' ); 151 152 $current_time_gmt = current_time( $format, true ); 153 $current_time = current_time( $format ); 154 155 $this->assertSame( gmdate( $format ), $current_time_custom_timezone_gmt, 'The dates should be equal [1]' ); 156 $this->assertSame( $datetime->format( $format ), $current_time_custom_timezone, 'The dates should be equal [2]' ); 157 $this->assertSame( gmdate( $format ), $current_time_gmt, 'The dates should be equal [3]' ); 158 $this->assertSame( $datetime->format( $format ), $current_time, 'The dates should be equal [4]' ); 159 } 131 160 }
Note: See TracChangeset
for help on using the changeset viewer.