| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * @group formatting |
| | 5 | */ |
| | 6 | class Tests_Formatting_ConvertDate extends WP_UnitTestCase { |
| | 7 | protected $originalTimezone; |
| | 8 | |
| | 9 | public function setUp() { |
| | 10 | $this->originalTimezone = get_option('timezone_string'); |
| | 11 | update_option('timezone_string', 'Europe/London'); |
| | 12 | } |
| | 13 | |
| | 14 | public function tearDown() { |
| | 15 | update_option('timezone_string', $this->originalTimezone); |
| | 16 | } |
| | 17 | |
| | 18 | /** |
| | 19 | * Check that dates both inside and outside DST have the correct offset applied |
| | 20 | */ |
| | 21 | function test_dst_respected_getting_local_date() { |
| | 22 | $gmtDateOutsideDst = '2012-01-01 12:34:56'; |
| | 23 | $expectedDateOutsideDst = $gmtDateOutsideDst; // no offset |
| | 24 | |
| | 25 | $this->assertSame($expectedDateOutsideDst, get_date_from_gmt($gmtDateOutsideDst)); |
| | 26 | |
| | 27 | $gmtDateInsideDst = '2012-06-01 12:34:56'; |
| | 28 | $expectedDateInsideDst = '2012-06-01 13:34:56'; |
| | 29 | |
| | 30 | $this->assertSame($expectedDateInsideDst, get_date_from_gmt($gmtDateInsideDst)); |
| | 31 | } |
| | 32 | |
| | 33 | function test_dst_respected_getting_gmt_date() { |
| | 34 | $localDateOutsideDst = '2012-01-01 12:34:56'; |
| | 35 | $expectedDateOutsideDst = $localDateOutsideDst; // no offset |
| | 36 | |
| | 37 | $this->assertSame($expectedDateOutsideDst, get_gmt_from_date($localDateOutsideDst)); |
| | 38 | |
| | 39 | $localDateInsideDst = '2012-06-01 12:34:56'; |
| | 40 | $expectedDateInsideDst = '2012-06-01 11:34:56'; |
| | 41 | |
| | 42 | $this->assertSame($expectedDateInsideDst, get_gmt_from_date($localDateInsideDst)); |
| | 43 | } |
| | 44 | } |