|
1 | 1 | <?php |
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.php |
| 6 | + * @group functions |
7 | 7 | * |
8 | 8 | * @covers ::wp_timezone_override_offset |
9 | 9 | */ |
10 | 10 | class Tests_Functions_wpTimezoneOverrideOffset extends WP_UnitTestCase { |
11 | | - /** |
12 | | - * @ticket 59980 |
13 | | - */ |
14 | | - public function test_wp_timezone_override_offset_with_no_timezone_string_option_set() { |
15 | | - $this->assertSame( '', get_option( 'timezone_string' ) ); |
16 | | - $this->assertFalse( wp_timezone_override_offset() ); |
17 | | - } |
18 | 11 |
|
19 | 12 | /** |
20 | 13 | * @ticket 59980 |
| 14 | + * |
| 15 | + * @dataProvider data_wp_timezone_override_offset |
21 | 16 | */ |
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() ); |
| 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() ); |
25 | 20 | } |
26 | 21 |
|
27 | 22 | /** |
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 |
| 23 | + * Data provider. |
| 24 | + * |
| 25 | + * @return array[] Test parameters { |
| 26 | + * @type string $timezone_string Test value. |
| 27 | + * @type string $expected Expected return value. |
| 28 | + * } |
47 | 29 | */ |
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 | } |
0 commit comments