From bab0ff1f5ebb1ca657d8e37d0303a44659a93300 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 16 Aug 2020 03:19:25 +0200 Subject: [PATCH] TRAC 46149 void | WAIT FOR 47381 + 46149 Ass | 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 ce63f0fa7e4bf..a752bd13e0790 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 a3450907aca55..1e506c282aaef 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 0087226ede654..eb25ffc226715 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 ); } /**