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
* 6205f33595

Follow-up to [51559-51570].

Props jrf.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@51571 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2021-08-07 10:51:59 +00:00
parent fcd4aa4700
commit 60dcae95ea
3 changed files with 6 additions and 6 deletions

View File

@ -485,7 +485,7 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
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 @@ class Tests_Comment_GetPageOfComment extends WP_UnitTestCase {
)
);
$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 );
}

View File

@ -891,8 +891,8 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase {
$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 );
}
/**

View File

@ -838,8 +838,8 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase {
$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 );
}
/**