From bbe419c14044da2a441d5cc5732031e08028d309 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 16 Aug 2020 03:19:25 +0200 Subject: [PATCH] Tests: fix tests failing due to `assertContains()` using strict checking Since PHPUnit 8.0.2, the `assertContains()` method when checking whether a value exists in an array will do a strict type comparison of the values. This caused a couple of tests to fail. Using the correct data type in the test fixes that. Refs: * https://github.com/sebastianbergmann/phpunit/blob/8.0.6/ChangeLog-8.0.md#802---2019-02-07 * https://github.com/sebastianbergmann/phpunit/issues/3511 * https://github.com/sebastianbergmann/phpunit/commit/6205f335954d00fa01992fe324a7eefbc954449e --- tests/phpunit/tests/comment/getPageOfComment.php | 4 ++-- tests/phpunit/tests/rest-api/rest-post-meta-fields.php | 4 ++-- tests/phpunit/tests/rest-api/rest-term-meta-fields.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/tests/comment/getPageOfComment.php b/tests/phpunit/tests/comment/getPageOfComment.php index 7a0bd729b3821..102e98aaa9b89 100644 --- a/tests/phpunit/tests/comment/getPageOfComment.php +++ b/tests/phpunit/tests/comment/getPageOfComment.php @@ -485,7 +485,7 @@ public function test_page_number_when_unapproved_comments_are_included_for_curre remove_filter( 'wp_get_current_commenter', array( $this, 'get_current_commenter' ) ); - $this->assertContains( $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); + $this->assertContains( (string) $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); } /** @@ -534,7 +534,7 @@ public function test_page_number_when_unapproved_comments_are_included_for_curre ) ); - $this->assertContains( $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); + $this->assertContains( (string) $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) ); wp_set_current_user( $current_user ); } diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php index ab5f50e3e3633..5e3122ea73c37 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -891,8 +891,8 @@ public function test_set_value_multiple_custom_schema() { $meta = get_post_meta( self::$post_id, 'test_custom_schema_multi', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 2, $meta ); - $this->assertContains( 2, $meta ); - $this->assertContains( 8, $meta ); + $this->assertContains( '2', $meta ); + $this->assertContains( '8', $meta ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php index c9cb763b58382..e3a94552ab043 100644 --- a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php @@ -838,8 +838,8 @@ public function test_set_value_multiple_custom_schema() { $meta = get_term_meta( self::$category_id, 'test_custom_schema_multi', false ); $this->assertNotEmpty( $meta ); $this->assertCount( 2, $meta ); - $this->assertContains( 2, $meta ); - $this->assertContains( 8, $meta ); + $this->assertContains( '2', $meta ); + $this->assertContains( '8', $meta ); } /**