Make WordPress Core


Ignore:
Timestamp:
01/28/2020 12:51:42 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Disable WPCS warnings for date_default_timezone_set() and current_time( 'timestamp' ) calls in Date/Time tests.

These calls are intentional and required for the tests.

See #49222.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/date/currentTime.php

    r47081 r47118  
    4444                $wp_timestamp = $timestamp + 6 * HOUR_IN_SECONDS;
    4545
     46                // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC
    4647                $this->assertEquals( $timestamp, current_time( 'timestamp', true ), 'The dates should be equal', 2 );
     48                // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
    4749                $this->assertEquals( $wp_timestamp, current_time( 'timestamp' ), 'The dates should be equal', 2 );
    4850        }
     
    5759                $datetime = new DateTime( 'now', new DateTimeZone( $timezone_string ) );
    5860
     61                // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    5962                date_default_timezone_set( $timezone_string );
    6063
     
    6265                $current_time_custom_timezone     = current_time( $format );
    6366
     67                // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    6468                date_default_timezone_set( 'UTC' );
    6569
     
    8488                $wp_timestamp = $timestamp + $datetime->getOffset();
    8589
     90                // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC
    8691                $this->assertEquals( $timestamp, current_time( 'timestamp', true ), 'The dates should be equal', 2 );
     92                // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC
    8793                $this->assertEquals( $timestamp, current_time( 'U', true ), 'The dates should be equal', 2 );
    8894
     95                // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
    8996                $this->assertEquals( $wp_timestamp, current_time( 'timestamp' ), 'The dates should be equal', 2 );
     97                // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
    9098                $this->assertEquals( $wp_timestamp, current_time( 'U' ), 'The dates should be equal', 2 );
    9199
     100                // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
    92101                $this->assertInternalType( 'int', current_time( 'timestamp' ) );
    93102        }
Note: See TracChangeset for help on using the changeset viewer.