Changeset 54230
- Timestamp:
- 09/19/2022 11:51:20 PM (2 years ago)
- Location:
- trunk/tests/phpunit/tests
- Files:
-
- 5 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 } -
trunk/tests/phpunit/tests/date/dateI18n.php
r54217 r54230 107 107 108 108 $this->assertSame( '2012-12-01 00:00:00 CST -06:00 America/Regina', date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2012-12-01 00:00:00' ) ) ); 109 } 110 111 /** 112 * Ensures that deprecated timezone strings are handled correctly. 113 * 114 * @ticket 56468 115 */ 116 public function test_adjusts_format_based_on_deprecated_timezone_string() { 117 update_option( 'timezone_string', 'America/Buenos_Aires' ); // This timezone was deprecated pre-PHP 5.6. 118 119 $expected = '2022-08-01 00:00:00 -03 -03:00 America/Buenos_Aires'; 120 if ( PHP_VERSION_ID < 70000 ) { 121 // PHP 5.6. 122 $expected = '2022-08-01 00:00:00 ART -03:00 America/Buenos_Aires'; 123 } 124 125 $this->assertSame( $expected, date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2022-08-01 00:00:00' ) ) ); 109 126 } 110 127 -
trunk/tests/phpunit/tests/date/mysql2date.php
r54217 r54230 64 64 65 65 /** 66 * Ensures that deprecated timezone strings are handled correctly. 67 * 68 * @ticket 56468 69 */ 70 public function test_mysql2date_should_format_time_with_deprecated_time_zone() { 71 $timezone = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6. 72 update_option( 'timezone_string', $timezone ); 73 $datetime = new DateTime( 'now', new DateTimeZone( $timezone ) ); 74 $rfc3339 = $datetime->format( DATE_RFC3339 ); 75 $mysql = $datetime->format( 'Y-m-d H:i:s' ); 76 77 $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql ) ); 78 $this->assertSame( $rfc3339, mysql2date( DATE_RFC3339, $mysql, false ) ); 79 } 80 81 /** 66 82 * @ticket 28992 67 83 */ -
trunk/tests/phpunit/tests/date/wpTimezone.php
r54217 r54230 50 50 51 51 $this->assertSame( 'Europe/Helsinki', $timezone->getName() ); 52 } 53 54 /** 55 * Ensures that deprecated timezone strings are handled correctly. 56 * 57 * @ticket 56468 58 */ 59 public function test_should_return_deprecated_timezone_string() { 60 $tz_string = 'America/Buenos_Aires'; // This timezone was deprecated pre-PHP 5.6. 61 update_option( 'timezone_string', $tz_string ); 62 63 $this->assertSame( $tz_string, wp_timezone_string() ); 64 65 $timezone = wp_timezone(); 66 67 $this->assertSame( $tz_string, $timezone->getName() ); 52 68 } 53 69 -
trunk/tests/phpunit/tests/formatting/date.php
r54217 r54230 241 241 'gmt_offset' => 3, 242 242 ), 243 // @ticket 56468. 244 'deprecated timezone string and no GMT offset set' => array( 245 'timezone_string' => 'America/Buenos_Aires', 246 'gmt_offset' => 0, 247 ), 243 248 ); 244 249 }
Note: See TracChangeset
for help on using the changeset viewer.