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

@@ -190,7 +190,7 @@ class Tests_Query extends WP_UnitTestCase {
$matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
$this->assertEqualSets( array( $p1, $p2 ), $matching_posts );
$this->assertSameSets( array( $p1, $p2 ), $matching_posts );
}
public function test_category_querystring_multiple_terms_comma_separated() {
@@ -234,7 +234,7 @@ class Tests_Query extends WP_UnitTestCase {
$matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
$this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
$this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
}
/**
@@ -281,7 +281,7 @@ class Tests_Query extends WP_UnitTestCase {
$matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
$this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
$this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
}
@@ -318,7 +318,7 @@ class Tests_Query extends WP_UnitTestCase {
$matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
$this->assertEqualSets( array( $p1, $p2 ), $matching_posts );
$this->assertSameSets( array( $p1, $p2 ), $matching_posts );
}
public function test_tag_querystring_multiple_terms_comma_separated() {
@@ -362,7 +362,7 @@ class Tests_Query extends WP_UnitTestCase {
$matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
$this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
$this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
}
/**
@@ -409,7 +409,7 @@ class Tests_Query extends WP_UnitTestCase {
$matching_posts = wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' );
$this->assertEqualSets( array( $p1, $p2, $p3 ), $matching_posts );
$this->assertSameSets( array( $p1, $p2, $p3 ), $matching_posts );
}
public function test_custom_taxonomy_querystring_single_term() {
@@ -436,7 +436,7 @@ class Tests_Query extends WP_UnitTestCase {
$this->go_to( $url );
$this->assertEqualSets( array( $p1, $p2 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
$this->assertSameSets( array( $p1, $p2 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
}
public function test_custom_taxonomy_querystring_multiple_terms_comma_separated() {
@@ -465,7 +465,7 @@ class Tests_Query extends WP_UnitTestCase {
$this->go_to( $url );
$this->assertEqualSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
$this->assertSameSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
}
/**
@@ -497,7 +497,7 @@ class Tests_Query extends WP_UnitTestCase {
$this->go_to( $url );
$this->assertEqualSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
$this->assertSameSets( array( $p1, $p2, $p3 ), wp_list_pluck( $GLOBALS['wp_query']->posts, 'ID' ) );
}
/**