WordPress.org

Make WordPress Core

Changeset 47118


Ignore:
Timestamp:
01/28/2020 12:51:42 AM (13 months 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.

Location:
trunk/tests/phpunit/tests
Files:
4 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    }
  • trunk/tests/phpunit/tests/date/getPermalink.php

    r46795 r47118  
    1111        delete_option( 'permalink_structure' );
    1212        update_option( 'timezone_string', 'UTC' );
     13        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    1314        date_default_timezone_set( 'UTC' );
    1415
     
    2324        update_option( 'timezone_string', $timezone );
    2425        update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%hour%/%minute%/%second%' );
     26        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    2527        date_default_timezone_set( 'UTC' );
    2628
     
    3436        $this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
    3537
     38        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    3639        date_default_timezone_set( $timezone );
    3740        $this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) );
  • trunk/tests/phpunit/tests/date/mysql2date.php

    r46586 r47118  
    88
    99    function tearDown() {
     10        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    1011        date_default_timezone_set( 'UTC' );
    1112
     
    3233    function test_mysql2date_should_format_time_with_changed_time_zone() {
    3334        $timezone = 'Europe/Kiev';
     35        // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
    3436        date_default_timezone_set( $timezone );
    3537        update_option( 'timezone_string', $timezone );
  • trunk/tests/phpunit/tests/rest-api/rest-categories-controller.php

    r46657 r47118  
    999999            'id',
    10001000            $this->factory->category->create(
    1001                 [
     1001                array(
    10021002                    'parent' => $old_parent_term->term_id,
    1003                 ]
     1003                )
    10041004            ),
    10051005            'category'
Note: See TracChangeset for help on using the changeset viewer.