Tests: Use assertSameSets() in some newly introduced tests.

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

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

Follow-up to [48939], [51137], [51943], [53499], [53504], [53506], [53509].

See #55652.

git-svn-id: https://develop.svn.wordpress.org/trunk@53510 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-06-15 14:42:58 +00:00
parent 8f219cdd78
commit 5b048f5a4e
3 changed files with 5 additions and 5 deletions

View File

@ -230,7 +230,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
$args = $action->get_args();
$last = end( $args );
$this->assertEqualSets( array( $post_id ), $last[1], '_prime_post_caches() was not executed.' );
$this->assertSameSets( array( $post_id ), $last[1], '_prime_post_caches() was not executed.' );
}
/**
@ -262,7 +262,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase {
$args = $action->get_args();
$last = end( $args );
$this->assertEqualSets( array( $term_id ), $last[1], '_prime_term_caches() was not executed.' );
$this->assertSameSets( array( $term_id ), $last[1], '_prime_term_caches() was not executed.' );
}
/**

View File

@ -1548,7 +1548,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$args = $filter->get_args();
$last = end( $args );
$this->assertIsArray( $last, 'The last value is not an array' );
$this->assertEqualSets( $attachment_ids, $last[1] );
$this->assertSameSets( $attachment_ids, $last[1] );
}
/**
@ -1591,7 +1591,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$args = $filter->get_args();
$last = end( $args );
$this->assertIsArray( $last, 'The last value is not an array' );
$this->assertEqualSets( $parent_ids, $last[1] );
$this->assertSameSets( $parent_ids, $last[1] );
}
public function test_get_items_pagination_headers() {

View File

@ -192,7 +192,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
$response = rest_get_server()->dispatch( $request );
$data = $response->get_data();
$keys = array_keys( $data['endpoints'][0]['args'] );
$this->assertEqualSets(
$this->assertSameSets(
array(
'context',
'exclude',