From 5b048f5a4e3778e1f4ce35d1cf6138ad5232500f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 15 Jun 2022 14:42:58 +0000 Subject: [PATCH] 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 --- tests/phpunit/tests/post/nav-menu.php | 4 ++-- tests/phpunit/tests/rest-api/rest-posts-controller.php | 4 ++-- tests/phpunit/tests/rest-api/rest-users-controller.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 4c2f2146f7..1f512812a5 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -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.' ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index 1f6187a3d0..117d773b64 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -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() { diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 4a28f210a1..c83c59d21d 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -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',