Changeset 59936
- Timestamp:
- 03/05/2025 01:13:14 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/wpTimezoneOverrideOffset.php
r59931 r59936 2 2 3 3 /** 4 * Tests for the wp_timezone_override_offset function.4 * Tests for the wp_timezone_override_offset() function. 5 5 * 6 * @group Functions.php6 * @group functions 7 7 * 8 8 * @covers ::wp_timezone_override_offset 9 9 */ 10 10 class Tests_Functions_wpTimezoneOverrideOffset extends WP_UnitTestCase { 11 11 12 /** 12 13 * @ticket 59980 14 * 15 * @dataProvider data_wp_timezone_override_offset 13 16 */ 14 public function test_wp_timezone_override_offset _with_no_timezone_string_option_set() {15 $this->assertSame( '', get_option( 'timezone_string' ));16 $this->assert False(wp_timezone_override_offset() );17 public function test_wp_timezone_override_offset( $timezone_string, $expected ) { 18 update_option( 'timezone_string', $timezone_string ); 19 $this->assertSame( $expected, wp_timezone_override_offset() ); 17 20 } 18 21 19 22 /** 20 * @ticket 59980 23 * Data provider. 24 * 25 * @return array[] Test parameters { 26 * @type string $timezone_string Test value. 27 * @type string $expected Expected return value. 28 * } 21 29 */ 22 public function test_wp_timezone_override_offset_with_bad_option_set() { 23 update_option( 'timezone_string', 'BAD_TIME_ZONE' ); 24 $this->assertFalse( wp_timezone_override_offset() ); 25 } 26 27 /** 28 * @ticket 59980 29 */ 30 public function test_wp_timezone_override_offset_with_UTC_option_set() { 31 update_option( 'timezone_string', 'UTC' ); 32 $offset = wp_timezone_override_offset(); 33 $this->assertSame( 0.0, $offset ); 34 } 35 36 /** 37 * @ticket 59980 38 */ 39 public function test_wp_timezone_override_offset_with_EST_option_set() { 40 update_option( 'timezone_string', 'EST' ); 41 $offset = wp_timezone_override_offset(); 42 $this->assertSame( -5.0, $offset ); 43 } 44 45 /** 46 * @ticket 59980 47 */ 48 public function test_wp_timezone_override_offset_with_NST_option_set() { 49 update_option( 'timezone_string', 'America/St_Johns' ); 50 $offset = wp_timezone_override_offset(); 51 $this->assertSame( -3.5, $offset ); 30 public function data_wp_timezone_override_offset() { 31 return array( 32 'no timezone string option set' => array( '', false ), 33 'bad option set' => array( 'BAD_TIME_ZONE', false ), 34 'UTC option set' => array( 'UTC', 0.0 ), 35 'EST option set' => array( 'EST', -5.0 ), 36 'NST option set' => array( 'America/St_Johns', -3.5 ), 37 ); 52 38 } 53 39 }
Note: See TracChangeset
for help on using the changeset viewer.