Changeset 48952 for trunk/tests/phpunit/tests/date/currentTime.php
- Timestamp:
- 09/07/2020 03:12:17 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/date/currentTime.php
r47118 r48952 17 17 $wp_timestamp = $timestamp + 6 * HOUR_IN_SECONDS; 18 18 19 $this->assertEquals ( strtotime( gmdate( $format ) ), strtotime( current_time( $format, true ) ), 'The dates should be equal', 2);20 $this->assertEquals ( strtotime( gmdate( $format, $wp_timestamp ) ), strtotime( current_time( $format ) ), 'The dates should be equal', 2);19 $this->assertEqualsWithDelta( strtotime( gmdate( $format ) ), strtotime( current_time( $format, true ) ), 2, 'The dates should be equal' ); 20 $this->assertEqualsWithDelta( strtotime( gmdate( $format, $wp_timestamp ) ), strtotime( current_time( $format ) ), 2, 'The dates should be equal' ); 21 21 } 22 22 … … 31 31 $wp_timestamp = $timestamp + 6 * HOUR_IN_SECONDS; 32 32 33 $this->assertEquals ( strtotime( gmdate( $format ) ), strtotime( current_time( 'mysql', true ) ), 'The dates should be equal', 2);34 $this->assertEquals ( strtotime( gmdate( $format, $wp_timestamp ) ), strtotime( current_time( 'mysql' ) ), 'The dates should be equal', 2);33 $this->assertEqualsWithDelta( strtotime( gmdate( $format ) ), strtotime( current_time( 'mysql', true ) ), 2, 'The dates should be equal' ); 34 $this->assertEqualsWithDelta( strtotime( gmdate( $format, $wp_timestamp ) ), strtotime( current_time( 'mysql' ) ), 2, 'The dates should be equal' ); 35 35 } 36 36 … … 45 45 46 46 // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC 47 $this->assertEquals ( $timestamp, current_time( 'timestamp', true ), 'The dates should be equal', 2);47 $this->assertEqualsWithDelta( $timestamp, current_time( 'timestamp', true ), 2, 'The dates should be equal' ); 48 48 // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested 49 $this->assertEquals ( $wp_timestamp, current_time( 'timestamp' ), 'The dates should be equal', 2);49 $this->assertEqualsWithDelta( $wp_timestamp, current_time( 'timestamp' ), 2, 'The dates should be equal' ); 50 50 } 51 51 … … 71 71 $current_time = current_time( $format ); 72 72 73 $this->assertEquals ( strtotime( gmdate( $format ) ), strtotime( $current_time_custom_timezone_gmt ), 'The dates should be equal', 2);74 $this->assertEquals ( strtotime( $datetime->format( $format ) ), strtotime( $current_time_custom_timezone ), 'The dates should be equal', 2);75 $this->assertEquals ( strtotime( gmdate( $format ) ), strtotime( $current_time_gmt ), 'The dates should be equal', 2);76 $this->assertEquals ( strtotime( $datetime->format( $format ) ), strtotime( $current_time ), 'The dates should be equal', 2);73 $this->assertEqualsWithDelta( strtotime( gmdate( $format ) ), strtotime( $current_time_custom_timezone_gmt ), 2, 'The dates should be equal' ); 74 $this->assertEqualsWithDelta( strtotime( $datetime->format( $format ) ), strtotime( $current_time_custom_timezone ), 2, 'The dates should be equal' ); 75 $this->assertEqualsWithDelta( strtotime( gmdate( $format ) ), strtotime( $current_time_gmt ), 2, 'The dates should be equal' ); 76 $this->assertEqualsWithDelta( strtotime( $datetime->format( $format ) ), strtotime( $current_time ), 2, 'The dates should be equal' ); 77 77 } 78 78 … … 89 89 90 90 // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC 91 $this->assertEquals ( $timestamp, current_time( 'timestamp', true ), 'The dates should be equal', 2);91 $this->assertEqualsWithDelta( $timestamp, current_time( 'timestamp', true ), 2, 'The dates should be equal' ); 92 92 // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC 93 $this->assertEquals ( $timestamp, current_time( 'U', true ), 'The dates should be equal', 2);93 $this->assertEqualsWithDelta( $timestamp, current_time( 'U', true ), 2, 'The dates should be equal' ); 94 94 95 95 // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested 96 $this->assertEquals ( $wp_timestamp, current_time( 'timestamp' ), 'The dates should be equal', 2);96 $this->assertEqualsWithDelta( $wp_timestamp, current_time( 'timestamp' ), 2, 'The dates should be equal' ); 97 97 // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested 98 $this->assertEquals ( $wp_timestamp, current_time( 'U' ), 'The dates should be equal', 2);98 $this->assertEqualsWithDelta( $wp_timestamp, current_time( 'U' ), 2, 'The dates should be equal' ); 99 99 100 100 // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested … … 114 114 $datetime_utc->setTimezone( new DateTimeZone( 'UTC' ) ); 115 115 116 $this->assertEquals ( strtotime( $datetime_local->format( DATE_W3C ) ), strtotime( current_time( DATE_W3C ) ), 'The dates should be equal', 2);117 $this->assertEquals ( strtotime( $datetime_utc->format( DATE_W3C ) ), strtotime( current_time( DATE_W3C, true ) ), 'The dates should be equal', 2);116 $this->assertEqualsWithDelta( strtotime( $datetime_local->format( DATE_W3C ) ), strtotime( current_time( DATE_W3C ) ), 2, 'The dates should be equal' ); 117 $this->assertEqualsWithDelta( strtotime( $datetime_utc->format( DATE_W3C ) ), strtotime( current_time( DATE_W3C, true ) ), 2, 'The dates should be equal' ); 118 118 } 119 119 }
Note: See TracChangeset
for help on using the changeset viewer.