Changeset 45857 for trunk/tests/phpunit/tests/date/currentTime.php
- Timestamp:
- 08/20/2019 01:34:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/date/currentTime.php
r45856 r45857 17 17 18 18 date_default_timezone_set( $timezone_string ); 19 $this->assertEquals( gmdate( $format ), current_time( $format, true ) ); 20 $this->assertEquals( $datetime->format( $format ), current_time( $format ) ); 19 20 $current_time_custom_timezone_gmt = current_time( $format, true ); 21 $current_time_custom_timezone = current_time( $format ); 21 22 22 23 date_default_timezone_set( 'UTC' ); 23 $this->assertEquals( gmdate( $format ), current_time( $format, true ) ); 24 $this->assertEquals( $datetime->format( $format ), current_time( $format ) ); 24 25 $current_time_gmt = current_time( $format, true ); 26 $current_time = current_time( $format ); 27 28 $this->assertEquals( strtotime( gmdate( $format ) ), strtotime( $current_time_custom_timezone_gmt ), 'The dates should be equal', 2 ); 29 $this->assertEquals( strtotime( $datetime->format( $format ) ), strtotime( $current_time_custom_timezone ), 'The dates should be equal', 2 ); 30 $this->assertEquals( strtotime( gmdate( $format ) ), strtotime( $current_time_gmt ), 'The dates should be equal', 2 ); 31 $this->assertEquals( strtotime( $datetime->format( $format ) ), strtotime( $current_time ), 'The dates should be equal', 2 ); 25 32 } 26 33 … … 30 37 public function test_should_return_wp_timestamp() { 31 38 update_option( 'timezone_string', 'Europe/Kiev' ); 39 32 40 $timestamp = time(); 33 41 $datetime = new DateTime( '@' . $timestamp ); … … 35 43 $wp_timestamp = $timestamp + $datetime->getOffset(); 36 44 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 ); 45 $this->assertEquals( $timestamp, current_time( 'timestamp', true ), 'The dates should be equal', 2 ); 46 $this->assertEquals( $timestamp, current_time( 'U', true ), 'The dates should be equal', 2 ); 47 48 $this->assertEquals( $wp_timestamp, current_time( 'timestamp' ), 'The dates should be equal', 2 ); 49 $this->assertEquals( $wp_timestamp, current_time( 'U' ), 'The dates should be equal', 2 ); 50 41 51 $this->assertInternalType( 'int', current_time( 'timestamp' ) ); 42 52 } … … 47 57 public function test_should_return_correct_local_time() { 48 58 update_option( 'timezone_string', 'Europe/Kiev' ); 59 49 60 $timestamp = time(); 50 61 $datetime_local = new DateTime( '@' . $timestamp ); … … 53 64 $datetime_utc->setTimezone( new DateTimeZone( 'UTC' ) ); 54 65 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 );66 $this->assertEquals( strtotime( $datetime_local->format( DATE_W3C ) ), strtotime( current_time( DATE_W3C ) ), 'The dates should be equal', 2 ); 67 $this->assertEquals( strtotime( $datetime_utc->format( DATE_W3C ) ), strtotime( current_time( DATE_W3C, true ) ), 'The dates should be equal', 2 ); 57 68 } 58 69 }
Note: See TracChangeset
for help on using the changeset viewer.