From 3d259c2b223ca80b2ec97e2df2a2d16a3b5d3b00 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 10 Feb 2021 13:24:24 +0000 Subject: [PATCH] Tests: Use `assertSame()` in some newly introduced tests. This ensures that not only the return values match the expected results, but also that their type is the same. Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable. Follow-up to [49904], [49925], [49992], [50012], [50013], [50065], [50075], [50131], [50150], [50157]. See #38266, #52482. git-svn-id: https://develop.svn.wordpress.org/trunk@50284 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/auth.php | 2 +- tests/phpunit/tests/functions.php | 2 +- tests/phpunit/tests/https-detection.php | 22 +++---- tests/phpunit/tests/https-migration.php | 16 ++--- tests/phpunit/tests/post.php | 58 +++++++++---------- tests/phpunit/tests/post/nav-menu.php | 10 ++-- .../rest-application-passwords-controller.php | 4 +- .../tests/rest-api/rest-posts-controller.php | 2 +- tests/phpunit/tests/rest-api/rest-request.php | 8 +-- tests/phpunit/tests/rest-api/rest-server.php | 4 +- .../tests/rest-api/rest-themes-controller.php | 10 ++-- tests/phpunit/tests/robots.php | 2 +- 12 files changed, 70 insertions(+), 70 deletions(-) diff --git a/tests/phpunit/tests/auth.php b/tests/phpunit/tests/auth.php index c52b37db6d..de0a498b84 100644 --- a/tests/phpunit/tests/auth.php +++ b/tests/phpunit/tests/auth.php @@ -468,7 +468,7 @@ class Tests_Auth extends WP_UnitTestCase { wp_validate_application_password( null ), 'Application passwords should be allowed for API authentication' ); - $this->assertEquals( $item['uuid'], rest_get_authenticated_app_password() ); + $this->assertSame( $item['uuid'], rest_get_authenticated_app_password() ); } /** diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 4f6a411694..f485d3b4ec 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -281,7 +281,7 @@ class Tests_Functions extends WP_UnitTestCase { $callback_value = $property->getValue( $new_value ); $this->assertSame( null, $callback_value ); } else { - $this->assertEquals( $value->count(), unserialize( $serialized )->count() ); + $this->assertSame( $value->count(), unserialize( $serialized )->count() ); } } diff --git a/tests/phpunit/tests/https-detection.php b/tests/phpunit/tests/https-detection.php index 3fcd8bcbb9..70eeef51fd 100644 --- a/tests/phpunit/tests/https-detection.php +++ b/tests/phpunit/tests/https-detection.php @@ -65,14 +65,14 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { // If initial request succeeds, all good. add_filter( 'pre_http_request', array( $this, 'mock_success_with_sslverify' ), 10, 2 ); wp_update_https_detection_errors(); - $this->assertEquals( array(), get_option( 'https_detection_errors' ) ); + $this->assertSame( array(), get_option( 'https_detection_errors' ) ); // If initial request fails and request without SSL verification succeeds, // return error with 'ssl_verification_failed' error code. add_filter( 'pre_http_request', array( $this, 'mock_error_with_sslverify' ), 10, 2 ); add_filter( 'pre_http_request', array( $this, 'mock_success_without_sslverify' ), 10, 2 ); wp_update_https_detection_errors(); - $this->assertEquals( + $this->assertSame( array( 'ssl_verification_failed' => array( 'Bad SSL certificate.' ) ), get_option( 'https_detection_errors' ) ); @@ -82,7 +82,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { add_filter( 'pre_http_request', array( $this, 'mock_error_with_sslverify' ), 10, 2 ); add_filter( 'pre_http_request', array( $this, 'mock_error_without_sslverify' ), 10, 2 ); wp_update_https_detection_errors(); - $this->assertEquals( + $this->assertSame( array( 'bad_ssl_certificate' => array( 'Bad SSL certificate.' ) ), get_option( 'https_detection_errors' ) ); @@ -91,7 +91,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { // 'bad_response_code' error code. add_filter( 'pre_http_request', array( $this, 'mock_not_found' ), 10, 2 ); wp_update_https_detection_errors(); - $this->assertEquals( + $this->assertSame( array( 'bad_response_code' => array( 'Not Found' ) ), get_option( 'https_detection_errors' ) ); @@ -100,13 +100,13 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { // WordPress site, return error with 'bad_response_source' error code. add_filter( 'pre_http_request', array( $this, 'mock_bad_source' ), 10, 2 ); wp_update_https_detection_errors(); - $this->assertEquals( + $this->assertSame( array( 'bad_response_source' => array( 'It looks like the response did not come from this site.' ) ), get_option( 'https_detection_errors' ) ); // Check that the requests are made to the correct URL. - $this->assertEquals( 'https://example.com/', $this->last_request_url ); + $this->assertSame( 'https://example.com/', $this->last_request_url ); } /** @@ -121,7 +121,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { } ); wp_update_https_detection_errors(); - $this->assertEquals( array(), get_option( 'https_detection_errors' ) ); + $this->assertSame( array(), get_option( 'https_detection_errors' ) ); // Override to enforce an error being detected. add_filter( @@ -134,7 +134,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { } ); wp_update_https_detection_errors(); - $this->assertEquals( + $this->assertSame( array( 'ssl_verification_failed' => array( 'Bad SSL certificate.' ) ), get_option( 'https_detection_errors' ) ); @@ -145,7 +145,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { */ public function test_wp_schedule_https_detection() { wp_schedule_https_detection(); - $this->assertEquals( 'twicedaily', wp_get_schedule( 'wp_https_detection' ) ); + $this->assertSame( 'twicedaily', wp_get_schedule( 'wp_https_detection' ) ); } /** @@ -157,7 +157,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { 'url' => 'http://example.com/', 'args' => array( 'sslverify' => true ), ); - $this->assertEquals( $request, wp_cron_conditionally_prevent_sslverify( $request ) ); + $this->assertSame( $request, wp_cron_conditionally_prevent_sslverify( $request ) ); // If URL is using HTTPS, set 'sslverify' to false. $request = array( @@ -166,7 +166,7 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase { ); $expected = $request; $expected['args']['sslverify'] = false; - $this->assertEquals( $expected, wp_cron_conditionally_prevent_sslverify( $request ) ); + $this->assertSame( $expected, wp_cron_conditionally_prevent_sslverify( $request ) ); } /** diff --git a/tests/phpunit/tests/https-migration.php b/tests/phpunit/tests/https-migration.php index 6486f99bb3..dccf40b602 100644 --- a/tests/phpunit/tests/https-migration.php +++ b/tests/phpunit/tests/https-migration.php @@ -61,11 +61,11 @@ class Tests_HTTPS_Migration extends WP_UnitTestCase { // Replaces URLs, including its encoded variant. add_filter( 'wp_should_replace_insecure_home_url', '__return_true' ); - $this->assertEquals( $https_content, wp_replace_insecure_home_url( $http_content ) ); + $this->assertSame( $https_content, wp_replace_insecure_home_url( $http_content ) ); // Does not replace anything if determined as unnecessary. add_filter( 'wp_should_replace_insecure_home_url', '__return_false' ); - $this->assertEquals( $http_content, wp_replace_insecure_home_url( $http_content ) ); + $this->assertSame( $http_content, wp_replace_insecure_home_url( $http_content ) ); } /** @@ -86,8 +86,8 @@ class Tests_HTTPS_Migration extends WP_UnitTestCase { // Update URLs to HTTPS (successfully). $this->assertTrue( wp_update_urls_to_https() ); - $this->assertEquals( $https_url, get_option( 'home' ) ); - $this->assertEquals( $https_url, get_option( 'siteurl' ) ); + $this->assertSame( $https_url, get_option( 'home' ) ); + $this->assertSame( $https_url, get_option( 'siteurl' ) ); // Switch options back to use HTTP URLs, but now add filter to // force option value which will make the update irrelevant. @@ -98,8 +98,8 @@ class Tests_HTTPS_Migration extends WP_UnitTestCase { // Update URLs to HTTPS. While the update technically succeeds, it does not take effect due to the enforced // option. Therefore the change is expected to be reverted. $this->assertFalse( wp_update_urls_to_https() ); - $this->assertEquals( $http_url, get_option( 'home' ) ); - $this->assertEquals( $http_url, get_option( 'siteurl' ) ); + $this->assertSame( $http_url, get_option( 'home' ) ); + $this->assertSame( $http_url, get_option( 'siteurl' ) ); } /** @@ -109,7 +109,7 @@ class Tests_HTTPS_Migration extends WP_UnitTestCase { // Changing HTTP to HTTPS on a site with content should result in flag being set, requiring migration. update_option( 'fresh_site', '0' ); wp_update_https_migration_required( 'http://example.org', 'https://example.org' ); - $this->assertEquals( '1', get_option( 'https_migration_required' ) ); + $this->assertTrue( get_option( 'https_migration_required' ) ); // Changing another part than the scheme should delete/reset the flag because changing those parts (e.g. the // domain) can have further implications. @@ -119,7 +119,7 @@ class Tests_HTTPS_Migration extends WP_UnitTestCase { // Changing HTTP to HTTPS on a site without content should result in flag being set, but not requiring migration. update_option( 'fresh_site', '1' ); wp_update_https_migration_required( 'http://example.org', 'https://example.org' ); - $this->assertEquals( '', get_option( 'https_migration_required' ) ); + $this->assertFalse( get_option( 'https_migration_required' ) ); // Changing (back) from HTTPS to HTTP should delete/reset the flag. wp_update_https_migration_required( 'https://example.org', 'http://example.org' ); diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 9c0b5a2e0a..2a3fb2a70b 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -1411,7 +1411,7 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date ), 2, 'The dates should be equal' ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); $post_id = self::factory()->post->create( array( @@ -1421,7 +1421,7 @@ class Tests_Post extends WP_UnitTestCase { ); $post = get_post( $post_id ); $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $post->post_date ), 2, 'The dates should be equal' ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); // Empty post_date_gmt without floating status $post_id = self::factory()->post->create( @@ -1450,8 +1450,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( get_date_from_gmt( $post_date_gmt ), $post->post_date ); - $this->assertEquals( $post_date_gmt, $post->post_date_gmt ); + $this->assertSame( get_date_from_gmt( $post_date_gmt ), $post->post_date ); + $this->assertSame( $post_date_gmt, $post->post_date_gmt ); // Invalid post_date_gmt $post_id = self::factory()->post->create( @@ -1460,8 +1460,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( '1970-01-01 00:00:00', $post->post_date ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( '1970-01-01 00:00:00', $post->post_date ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); } /** @@ -1480,8 +1480,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( $post_date, $post->post_date ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( $post_date, $post->post_date ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); $post_id = self::factory()->post->create( array( @@ -1491,8 +1491,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( $post_date, $post->post_date ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( $post_date, $post->post_date ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); // Empty post_date_gmt without floating status $post_id = self::factory()->post->create( @@ -1502,8 +1502,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( $post_date, $post->post_date ); - $this->assertEquals( get_gmt_from_date( $post_date ), $post->post_date_gmt ); + $this->assertSame( $post_date, $post->post_date ); + $this->assertSame( get_gmt_from_date( $post_date ), $post->post_date_gmt ); $post_id = self::factory()->post->create( array( @@ -1513,8 +1513,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( $post_date, $post->post_date ); - $this->assertEquals( get_gmt_from_date( $post_date ), $post->post_date_gmt ); + $this->assertSame( $post_date, $post->post_date ); + $this->assertSame( get_gmt_from_date( $post_date ), $post->post_date_gmt ); // Valid post_date_gmt $post_id = self::factory()->post->create( @@ -1524,8 +1524,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( $post_date, $post->post_date ); - $this->assertEquals( $post_date_gmt, $post->post_date_gmt ); + $this->assertSame( $post_date, $post->post_date ); + $this->assertSame( $post_date_gmt, $post->post_date_gmt ); // Invalid post_date_gmt $post_id = self::factory()->post->create( @@ -1535,8 +1535,8 @@ class Tests_Post extends WP_UnitTestCase { ) ); $post = get_post( $post_id ); - $this->assertEquals( $post_date, $post->post_date ); - $this->assertEquals( '0000-00-00 00:00:00', $post->post_date_gmt ); + $this->assertSame( $post_date, $post->post_date ); + $this->assertSame( '0000-00-00 00:00:00', $post->post_date_gmt ); } /** @@ -1554,7 +1554,7 @@ class Tests_Post extends WP_UnitTestCase { 'post_status' => 'draft', ) ); - $this->assertEquals( 0, $post_id ); + $this->assertSame( 0, $post_id ); $post_id = self::factory()->post->create( array( @@ -1563,7 +1563,7 @@ class Tests_Post extends WP_UnitTestCase { 'post_status' => 'draft', ) ); - $this->assertEquals( 0, $post_id ); + $this->assertSame( 0, $post_id ); // Empty post_date_gmt without floating status $post_id = self::factory()->post->create( @@ -1572,7 +1572,7 @@ class Tests_Post extends WP_UnitTestCase { 'post_status' => 'publish', ) ); - $this->assertEquals( 0, $post_id ); + $this->assertSame( 0, $post_id ); $post_id = self::factory()->post->create( array( @@ -1581,7 +1581,7 @@ class Tests_Post extends WP_UnitTestCase { 'post_status' => 'publish', ) ); - $this->assertEquals( 0, $post_id ); + $this->assertSame( 0, $post_id ); // Valid post_date_gmt $post_id = self::factory()->post->create( @@ -1590,7 +1590,7 @@ class Tests_Post extends WP_UnitTestCase { 'post_date_gmt' => $post_date_gmt, ) ); - $this->assertEquals( 0, $post_id ); + $this->assertSame( 0, $post_id ); // Invalid post_date_gmt $post_id = self::factory()->post->create( @@ -1599,7 +1599,7 @@ class Tests_Post extends WP_UnitTestCase { 'post_date_gmt' => $invalid_date, ) ); - $this->assertEquals( 0, $post_id ); + $this->assertSame( 0, $post_id ); } /** @@ -1614,19 +1614,19 @@ class Tests_Post extends WP_UnitTestCase { $this->assertEqualsWithDelta( strtotime( gmdate( 'Y-m-d H:i:s' ) ), strtotime( $resolved_post_date ), 2, 'The dates should be equal' ); $resolved_post_date = wp_resolve_post_date( '', $post_date_gmt ); - $this->assertEquals( get_date_from_gmt( $post_date_gmt ), $resolved_post_date ); + $this->assertSame( get_date_from_gmt( $post_date_gmt ), $resolved_post_date ); $resolved_post_date = wp_resolve_post_date( '', $invalid_date ); - $this->assertEquals( '1970-01-01 00:00:00', $resolved_post_date ); + $this->assertSame( '1970-01-01 00:00:00', $resolved_post_date ); $resolved_post_date = wp_resolve_post_date( $post_date ); - $this->assertEquals( $post_date, $resolved_post_date ); + $this->assertSame( $post_date, $resolved_post_date ); $resolved_post_date = wp_resolve_post_date( $post_date, $post_date_gmt ); - $this->assertEquals( $post_date, $resolved_post_date ); + $this->assertSame( $post_date, $resolved_post_date ); $resolved_post_date = wp_resolve_post_date( $post_date, $invalid_date ); - $this->assertEquals( $post_date, $resolved_post_date ); + $this->assertSame( $post_date, $resolved_post_date ); $resolved_post_date = wp_resolve_post_date( $invalid_date ); $this->assertFalse( $resolved_post_date ); diff --git a/tests/phpunit/tests/post/nav-menu.php b/tests/phpunit/tests/post/nav-menu.php index 075138618a..3f82ed999c 100644 --- a/tests/phpunit/tests/post/nav-menu.php +++ b/tests/phpunit/tests/post/nav-menu.php @@ -1037,7 +1037,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { ) ); $post = get_post( $menu_item_id ); - $this->assertEquals( get_date_from_gmt( $post_date_gmt ), $post->post_date ); + $this->assertSame( get_date_from_gmt( $post_date_gmt ), $post->post_date ); $menu_item_id = wp_update_nav_menu_item( $this->menu_id, @@ -1051,7 +1051,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { ) ); $post = get_post( $menu_item_id ); - $this->assertEquals( '1970-01-01 00:00:00', $post->post_date ); + $this->assertSame( '1970-01-01 00:00:00', $post->post_date ); $menu_item_id = wp_update_nav_menu_item( $this->menu_id, @@ -1065,7 +1065,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { ) ); $post = get_post( $menu_item_id ); - $this->assertEquals( $post_date, $post->post_date ); + $this->assertSame( $post_date, $post->post_date ); $menu_item_id = wp_update_nav_menu_item( $this->menu_id, @@ -1080,7 +1080,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { ) ); $post = get_post( $menu_item_id ); - $this->assertEquals( $post_date, $post->post_date ); + $this->assertSame( $post_date, $post->post_date ); $menu_item_id = wp_update_nav_menu_item( $this->menu_id, @@ -1095,7 +1095,7 @@ class Tests_Post_Nav_Menu extends WP_UnitTestCase { ) ); $post = get_post( $menu_item_id ); - $this->assertEquals( $post_date, $post->post_date ); + $this->assertSame( $post_date, $post->post_date ); $menu_item_id = wp_update_nav_menu_item( $this->menu_id, diff --git a/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php b/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php index b55c8e082d..4b819426d6 100644 --- a/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php +++ b/tests/phpunit/tests/rest-api/rest-application-passwords-controller.php @@ -891,7 +891,7 @@ class WP_Test_REST_Application_Passwords_Controller extends WP_Test_REST_Control $response = rest_do_request( '/wp/v2/users/me/application-passwords/introspect' ); $this->assertNotWPError( $response->as_error() ); - $this->assertEquals( $password['uuid'], $response->get_data()['uuid'] ); + $this->assertSame( $password['uuid'], $response->get_data()['uuid'] ); } /** @@ -901,7 +901,7 @@ class WP_Test_REST_Application_Passwords_Controller extends WP_Test_REST_Control $password = $this->setup_app_password_authenticated_request(); $response = rest_do_request( '/wp/v2/users/' . self::$admin . '/application-passwords/introspect' ); - $this->assertEquals( $password['uuid'], $response->get_data()['uuid'] ); + $this->assertSame( $password['uuid'], $response->get_data()['uuid'] ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php index 39d1d77e9a..2d0e1767d0 100644 --- a/tests/phpunit/tests/rest-api/rest-posts-controller.php +++ b/tests/phpunit/tests/rest-api/rest-posts-controller.php @@ -1199,7 +1199,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te $data = $response->get_data(); $this->assertCount( 1, $data ); - $this->assertEquals( $post_ids[0], $data[0]['id'] ); + $this->assertSame( $post_ids[0], $data[0]['id'] ); } /** diff --git a/tests/phpunit/tests/rest-api/rest-request.php b/tests/phpunit/tests/rest-api/rest-request.php index 54afd39c7c..3502778972 100644 --- a/tests/phpunit/tests/rest-api/rest-request.php +++ b/tests/phpunit/tests/rest-api/rest-request.php @@ -494,7 +494,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->assertInternalType( 'array', $data ); $this->assertArrayHasKey( 'params', $data ); $this->assertArrayHasKey( 'failparam', $data['params'] ); - $this->assertEquals( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] ); + $this->assertSame( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] ); } /** @@ -524,7 +524,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $data = $valid->get_error_data(); $this->assertArrayHasKey( 'details', $data ); $this->assertArrayHasKey( 'failparam', $data['details'] ); - $this->assertEquals( + $this->assertSame( array( 'code' => 'invalid', 'message' => 'Invalid.', @@ -757,7 +757,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->assertInternalType( 'array', $data ); $this->assertArrayHasKey( 'params', $data ); $this->assertArrayHasKey( 'failparam', $data['params'] ); - $this->assertEquals( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] ); + $this->assertSame( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] ); } /** @@ -787,7 +787,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $data = $valid->get_error_data(); $this->assertArrayHasKey( 'details', $data ); $this->assertArrayHasKey( 'failparam', $data['details'] ); - $this->assertEquals( + $this->assertSame( array( 'code' => 'invalid', 'message' => 'Invalid.', diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index b47cacd245..0dbc308bf9 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -465,8 +465,8 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $response = rest_convert_error_to_response( $error ); $this->assertSame( 400, $response->get_status() ); - $this->assertEquals( 'more_data', $response->get_data()['data'] ); - $this->assertEquals( array( array( 'status' => 400 ) ), $response->get_data()['additional_data'] ); + $this->assertSame( 'more_data', $response->get_data()['data'] ); + $this->assertSame( array( array( 'status' => 400 ) ), $response->get_data()['additional_data'] ); } public function test_rest_error() { diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php index 86b3481c94..25265ca6fe 100644 --- a/tests/phpunit/tests/rest-api/rest-themes-controller.php +++ b/tests/phpunit/tests/rest-api/rest-themes-controller.php @@ -199,7 +199,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $fields = array( @@ -237,7 +237,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $this->assertContains( 'twentytwenty', wp_list_pluck( $data, 'stylesheet' ) ); @@ -297,7 +297,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { if ( $error_code ) { $this->assertErrorResponse( $error_code, $response, 403 ); } else { - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } } @@ -1215,7 +1215,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', $route ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); $data = $response->get_data(); $links = $response->get_links(); $fields = array( @@ -1278,7 +1278,7 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { $request = new WP_REST_Request( 'GET', $route ); $response = rest_get_server()->dispatch( $request ); - $this->assertEquals( 200, $response->get_status() ); + $this->assertSame( 200, $response->get_status() ); } /** diff --git a/tests/phpunit/tests/robots.php b/tests/phpunit/tests/robots.php index 8eb83281ec..a8073b36f3 100644 --- a/tests/phpunit/tests/robots.php +++ b/tests/phpunit/tests/robots.php @@ -29,7 +29,7 @@ class Tests_Robots extends WP_UnitTestCase { // Render robots meta tag with noindex. add_filter( 'wp_robots', array( $this, 'add_noindex_directive' ) ); $output = get_echo( 'wp_robots' ); - $this->assertEquals( "\n", $output ); + $this->assertSame( "\n", $output ); // Do not render robots meta tag when there are only false-y directives. add_filter( 'wp_robots', array( $this, 'remove_noindex_directive' ), 11 );