From 60dcae95ea9cfd168571cb06dad70fa230e68464 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 7 Aug 2021 10:51:59 +0000 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. References: * 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 Follow-up to [51559-51570]. Props jrf. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51571 602fd350-edb4-49c9-b593-d223f7449a82 --- 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 f62be6013715..7cdf85ba4127 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' ) ); } public function get_current_commenter() { @@ -542,7 +542,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 a3450907aca5..1e506c282aae 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 0087226ede65..eb25ffc22671 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 ); } /**