Tests: Introduce assertSameSets() and assertSameSetsWithIndex(), and use them where appropriate.

This ensures that not only the array values being compared are equal, but also that their type is the same.

These new methods replace most of the existing instances of `assertEqualSets()` and `assertEqualSetsWithIndex()`.

Going forward, stricter type checking by using `assertSameSets()` or `assertSameSetsWithIndex()` should generally be preferred, to make the tests more reliable.

Follow-up to [48937].

See #38266.

git-svn-id: https://develop.svn.wordpress.org/trunk@48939 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-09-04 07:01:00 +00:00
parent 5e2a75ef29
commit 8be943d06e
105 changed files with 757 additions and 729 deletions

View File

@@ -82,7 +82,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
self::$author_private_post,
);
$this->assertEqualSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
$this->assertSameSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
}
public function test_private_should_not_be_included_for_non_author_if_perm_is_not_false() {
@@ -112,7 +112,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
self::$author_private_post,
);
$this->assertEqualSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
$this->assertSameSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
}
public function test_private_should_be_included_for_all_users_if_perm_is_readable_and_user_can_read_others_posts() {
@@ -130,7 +130,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
self::$editor_private_post,
);
$this->assertEqualSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
$this->assertSameSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
}
public function test_private_should_be_included_only_for_current_user_if_perm_is_editable_and_user_cannot_read_others_posts() {
@@ -147,7 +147,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
self::$author_private_post,
);
$this->assertEqualSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
$this->assertSameSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
}
public function test_private_should_be_included_for_all_users_if_perm_is_editable_and_user_can_read_others_posts() {
@@ -165,7 +165,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase {
self::$editor_private_post,
);
$this->assertEqualSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
$this->assertSameSets( $expected, wp_list_pluck( $q->posts, 'ID' ) );
}
public function test_all_public_post_stati_should_be_included_when_no_post_status_is_provided() {