Skip to content

Commit

Permalink
Tests: fix tests failing due to assertContains() using strict checking
Browse files Browse the repository at this point in the history
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
* sebastianbergmann/phpunit#3511
* sebastianbergmann/phpunit@6205f33
  • Loading branch information
jrfnl committed Aug 7, 2021
1 parent 0d14d54 commit 230702c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/phpunit/tests/comment/getPageOfComment.php
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 );
}
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/rest-api/rest-post-meta-fields.php
Expand Up @@ -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 );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/tests/rest-api/rest-term-meta-fields.php
Expand Up @@ -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 );
}

/**
Expand Down

0 comments on commit 230702c

Please sign in to comment.