diff --git a/tests/phpunit/tests/date/currentTime.php b/tests/phpunit/tests/date/currentTime.php index 69354acde8..490a8c9070 100644 --- a/tests/phpunit/tests/date/currentTime.php +++ b/tests/phpunit/tests/date/currentTime.php @@ -43,7 +43,9 @@ class Tests_Date_Current_Time extends WP_UnitTestCase { $timestamp = time(); $wp_timestamp = $timestamp + 6 * HOUR_IN_SECONDS; + // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC $this->assertEquals( $timestamp, current_time( 'timestamp', true ), 'The dates should be equal', 2 ); + // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested $this->assertEquals( $wp_timestamp, current_time( 'timestamp' ), 'The dates should be equal', 2 ); } @@ -56,11 +58,13 @@ class Tests_Date_Current_Time extends WP_UnitTestCase { update_option( 'timezone_string', $timezone_string ); $datetime = new DateTime( 'now', new DateTimeZone( $timezone_string ) ); + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( $timezone_string ); $current_time_custom_timezone_gmt = current_time( $format, true ); $current_time_custom_timezone = current_time( $format ); + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( 'UTC' ); $current_time_gmt = current_time( $format, true ); @@ -83,12 +87,17 @@ class Tests_Date_Current_Time extends WP_UnitTestCase { $datetime->setTimezone( wp_timezone() ); $wp_timestamp = $timestamp + $datetime->getOffset(); + // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC $this->assertEquals( $timestamp, current_time( 'timestamp', true ), 'The dates should be equal', 2 ); + // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.RequestedUTC $this->assertEquals( $timestamp, current_time( 'U', true ), 'The dates should be equal', 2 ); + // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested $this->assertEquals( $wp_timestamp, current_time( 'timestamp' ), 'The dates should be equal', 2 ); + // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested $this->assertEquals( $wp_timestamp, current_time( 'U' ), 'The dates should be equal', 2 ); + // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested $this->assertInternalType( 'int', current_time( 'timestamp' ) ); } diff --git a/tests/phpunit/tests/date/getPermalink.php b/tests/phpunit/tests/date/getPermalink.php index 0b6d86b13f..2b0e84f52b 100644 --- a/tests/phpunit/tests/date/getPermalink.php +++ b/tests/phpunit/tests/date/getPermalink.php @@ -10,6 +10,7 @@ class Tests_Date_Get_Permalink extends WP_UnitTestCase { function tearDown() { delete_option( 'permalink_structure' ); update_option( 'timezone_string', 'UTC' ); + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( 'UTC' ); parent::tearDown(); @@ -22,6 +23,7 @@ class Tests_Date_Get_Permalink extends WP_UnitTestCase { $timezone = 'America/Chicago'; update_option( 'timezone_string', $timezone ); update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%hour%/%minute%/%second%' ); + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( 'UTC' ); $post_id = self::factory()->post->create( @@ -33,6 +35,7 @@ class Tests_Date_Get_Permalink extends WP_UnitTestCase { $this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) ); + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( $timezone ); $this->assertEquals( 'http://example.org/2018/07/22/21/13/23', get_permalink( $post_id ) ); } diff --git a/tests/phpunit/tests/date/mysql2date.php b/tests/phpunit/tests/date/mysql2date.php index 3b73771827..25b0784e26 100644 --- a/tests/phpunit/tests/date/mysql2date.php +++ b/tests/phpunit/tests/date/mysql2date.php @@ -7,6 +7,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { function tearDown() { + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( 'UTC' ); parent::tearDown(); @@ -31,6 +32,7 @@ class Tests_Date_mysql2date extends WP_UnitTestCase { */ function test_mysql2date_should_format_time_with_changed_time_zone() { $timezone = 'Europe/Kiev'; + // phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set date_default_timezone_set( $timezone ); update_option( 'timezone_string', $timezone ); $datetime = new DateTime( 'now', new DateTimeZone( $timezone ) ); diff --git a/tests/phpunit/tests/rest-api/rest-categories-controller.php b/tests/phpunit/tests/rest-api/rest-categories-controller.php index 2035bdbf80..1f2228ff05 100644 --- a/tests/phpunit/tests/rest-api/rest-categories-controller.php +++ b/tests/phpunit/tests/rest-api/rest-categories-controller.php @@ -998,9 +998,9 @@ class WP_Test_REST_Categories_Controller extends WP_Test_REST_Controller_Testcas $term = get_term_by( 'id', $this->factory->category->create( - [ + array( 'parent' => $old_parent_term->term_id, - ] + ) ), 'category' );