Changeset 45856 for trunk/tests/phpunit/tests/date/currentTime.php
- Timestamp:
- 08/19/2019 09:05:42 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/date/currentTime.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/date/currentTime.php
r43594 r45856 7 7 class Tests_Date_CurrentTime extends WP_UnitTestCase { 8 8 9 /** 10 * @ticket 37440 11 */ 9 12 public function test_should_work_with_changed_timezone() { 10 11 13 $format = 'Y-m-d H:i:s'; 12 14 $timezone_string = 'America/Regina'; … … 22 24 $this->assertEquals( $datetime->format( $format ), current_time( $format ) ); 23 25 } 26 27 /** 28 * @ticket 40653 29 */ 30 public function test_should_return_wp_timestamp() { 31 update_option( 'timezone_string', 'Europe/Kiev' ); 32 $timestamp = time(); 33 $datetime = new DateTime( '@' . $timestamp ); 34 $datetime->setTimezone( wp_timezone() ); 35 $wp_timestamp = $timestamp + $datetime->getOffset(); 36 37 $this->assertEquals( $timestamp, current_time( 'timestamp', true ), '', 2 ); 38 $this->assertEquals( $timestamp, current_time( 'U', true ), '', 2 ); 39 $this->assertEquals( $wp_timestamp, current_time( 'timestamp' ), '', 2 ); 40 $this->assertEquals( $wp_timestamp, current_time( 'U' ), '', 2 ); 41 $this->assertInternalType( 'int', current_time( 'timestamp' ) ); 42 } 43 44 /** 45 * @ticket 40653 46 */ 47 public function test_should_return_correct_local_time() { 48 update_option( 'timezone_string', 'Europe/Kiev' ); 49 $timestamp = time(); 50 $datetime_local = new DateTime( '@' . $timestamp ); 51 $datetime_local->setTimezone( wp_timezone() ); 52 $datetime_utc = new DateTime( '@' . $timestamp ); 53 $datetime_utc->setTimezone( new DateTimeZone( 'UTC' ) ); 54 55 $this->assertEquals( $datetime_local->format( DATE_W3C ), current_time( DATE_W3C ), '', 2 ); 56 $this->assertEquals( $datetime_utc->format( DATE_W3C ), current_time( DATE_W3C, true ), '', 2 ); 57 } 24 58 }
Note: See TracChangeset
for help on using the changeset viewer.