Skip to content

Commit 60dcae9

Browse files
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 * sebastianbergmann/phpunit#3511 * sebastianbergmann/phpunit@6205f33 Follow-up to [51559-51570]. Props jrf. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51571 602fd350-edb4-49c9-b593-d223f7449a82
1 parent fcd4aa4 commit 60dcae9

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

tests/phpunit/tests/comment/getPageOfComment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ public function test_page_number_when_unapproved_comments_are_included_for_curre
485485

486486
remove_filter( 'wp_get_current_commenter', array( $this, 'get_current_commenter' ) );
487487

488-
$this->assertContains( $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) );
488+
$this->assertContains( (string) $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) );
489489
}
490490

491491
public function get_current_commenter() {
@@ -542,7 +542,7 @@ public function test_page_number_when_unapproved_comments_are_included_for_curre
542542
)
543543
);
544544

545-
$this->assertContains( $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) );
545+
$this->assertContains( (string) $new_unapproved, wp_list_pluck( $comments, 'comment_ID' ) );
546546

547547
wp_set_current_user( $current_user );
548548
}

tests/phpunit/tests/rest-api/rest-post-meta-fields.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ public function test_set_value_multiple_custom_schema() {
891891
$meta = get_post_meta( self::$post_id, 'test_custom_schema_multi', false );
892892
$this->assertNotEmpty( $meta );
893893
$this->assertCount( 2, $meta );
894-
$this->assertContains( 2, $meta );
895-
$this->assertContains( 8, $meta );
894+
$this->assertContains( '2', $meta );
895+
$this->assertContains( '8', $meta );
896896
}
897897

898898
/**

tests/phpunit/tests/rest-api/rest-term-meta-fields.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,8 @@ public function test_set_value_multiple_custom_schema() {
838838
$meta = get_term_meta( self::$category_id, 'test_custom_schema_multi', false );
839839
$this->assertNotEmpty( $meta );
840840
$this->assertCount( 2, $meta );
841-
$this->assertContains( 2, $meta );
842-
$this->assertContains( 8, $meta );
841+
$this->assertContains( '2', $meta );
842+
$this->assertContains( '8', $meta );
843843
}
844844

845845
/**

0 commit comments

Comments
 (0)