From 46a80bf2d47d9a9ac442b762821c3cc832281120 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 15 Aug 2020 17:47:03 +0200 Subject: [PATCH] Tests: replace `assert[Not]InternalType( 'string', $var )` with `assertIs[Not]String()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * https://github.com/sebastianbergmann/phpunit/issues/3368 --- tests/phpunit/tests/blocks/render.php | 2 +- tests/phpunit/tests/customize/manager.php | 4 +- .../tests/customize/selective-refresh.php | 6 +- tests/phpunit/tests/customize/setting.php | 2 +- tests/phpunit/tests/functions.php | 6 +- .../phpunit/tests/functions/wpRemoteFopen.php | 2 +- tests/phpunit/tests/general/archives.php | 24 +++---- tests/phpunit/tests/general/template.php | 2 +- tests/phpunit/tests/oembed/controller.php | 4 +- tests/phpunit/tests/post/objects.php | 2 +- .../tests/rest-api/rest-post-meta-fields.php | 2 +- .../tests/rest-api/rest-term-meta-fields.php | 2 +- .../tests/rest-api/rest-users-controller.php | 4 +- tests/phpunit/tests/term/termExists.php | 4 +- .../tests/theme/getThemeStarterContent.php | 4 +- tests/phpunit/tests/xmlrpc/mw/getPost.php | 30 ++++----- .../tests/xmlrpc/mw/getRecentPosts.php | 34 +++++----- tests/phpunit/tests/xmlrpc/wp/getComment.php | 26 ++++---- .../phpunit/tests/xmlrpc/wp/getMediaItem.php | 12 ++-- tests/phpunit/tests/xmlrpc/wp/getPage.php | 30 ++++----- tests/phpunit/tests/xmlrpc/wp/getPost.php | 34 +++++----- tests/phpunit/tests/xmlrpc/wp/getPostType.php | 66 +++++++++---------- tests/phpunit/tests/xmlrpc/wp/getTerm.php | 8 +-- tests/phpunit/tests/xmlrpc/wp/getUser.php | 20 +++--- tests/phpunit/tests/xmlrpc/wp/getUsers.php | 20 +++--- tests/phpunit/tests/xmlrpc/wp/uploadFile.php | 8 +-- 26 files changed, 179 insertions(+), 179 deletions(-) diff --git a/tests/phpunit/tests/blocks/render.php b/tests/phpunit/tests/blocks/render.php index 256089db2adb5..c7aa0cfc1b22d 100644 --- a/tests/phpunit/tests/blocks/render.php +++ b/tests/phpunit/tests/blocks/render.php @@ -324,7 +324,7 @@ public function test_dynamic_block_renders_string() { $rendered = $block_type->render(); $this->assertSame( '10', $rendered ); - $this->assertInternalType( 'string', $rendered ); + $this->assertIsString( $rendered ); } public function test_dynamic_block_gets_inner_html() { diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php index f65a7873b779b..03dc58e155573 100644 --- a/tests/phpunit/tests/customize/manager.php +++ b/tests/phpunit/tests/customize/manager.php @@ -2909,7 +2909,7 @@ function action_customize_register_for_dynamic_settings() { * @return array */ function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setting_args, $setting_id ) { - $this->assertInternalType( 'string', $setting_id ); + $this->assertIsString( $setting_id ); if ( in_array( $setting_id, array( 'foo', 'bar' ), true ) ) { $setting_args = array( 'default' => "dynamic_{$setting_id}_default" ); } @@ -2926,7 +2926,7 @@ function filter_customize_dynamic_setting_args_for_test_dynamic_settings( $setti */ function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) { $this->assertEquals( 'WP_Customize_Setting', $setting_class ); - $this->assertInternalType( 'string', $setting_id ); + $this->assertIsString( $setting_id ); $this->assertIsArray( $setting_args ); return $setting_class; } diff --git a/tests/phpunit/tests/customize/selective-refresh.php b/tests/phpunit/tests/customize/selective-refresh.php index 9f92dce9cde29..fd8b3c4807de8 100644 --- a/tests/phpunit/tests/customize/selective-refresh.php +++ b/tests/phpunit/tests/customize/selective-refresh.php @@ -208,7 +208,7 @@ function test_add_dynamic_partials() { */ function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) { $this->assertTrue( false === $partial_args || is_array( $partial_args ) ); - $this->assertInternalType( 'string', $partial_id ); + $this->assertIsString( $partial_id ); if ( preg_match( '/^recognized/', $partial_id ) ) { $partial_args = array( @@ -231,8 +231,8 @@ function filter_customize_dynamic_partial_args( $partial_args, $partial_id ) { */ function filter_customize_dynamic_partial_class( $partial_class, $partial_id, $partial_args ) { $this->assertIsArray( $partial_args ); - $this->assertInternalType( 'string', $partial_id ); - $this->assertInternalType( 'string', $partial_class ); + $this->assertIsString( $partial_id ); + $this->assertIsString( $partial_class ); if ( 'recognized-class' === $partial_id ) { $partial_class = 'Tested_Custom_Partial'; diff --git a/tests/phpunit/tests/customize/setting.php b/tests/phpunit/tests/customize/setting.php index 89562345cf770..375a5edf0d013 100644 --- a/tests/phpunit/tests/customize/setting.php +++ b/tests/phpunit/tests/customize/setting.php @@ -730,7 +730,7 @@ public function test_validate() { */ public function filter_validate_for_test_validate( $validity, $value ) { $this->assertInstanceOf( 'WP_Error', $validity ); - $this->assertInternalType( 'string', $value ); + $this->assertIsString( $value ); if ( sanitize_key( $value ) !== $value ) { $validity->add( 'invalid_key', 'Invalid key' ); } diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 734f1daa04df3..f228658410360 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -80,8 +80,8 @@ function test_wp_parse_args_other() { */ function test_wp_parse_args_boolean_strings() { $args = wp_parse_args( 'foo=false&bar=true' ); - $this->assertInternalType( 'string', $args['foo'] ); - $this->assertInternalType( 'string', $args['bar'] ); + $this->assertIsString( $args['foo'] ); + $this->assertIsString( $args['bar'] ); } /** @@ -1179,7 +1179,7 @@ function test_wp_unique_id() { $ids = array(); for ( $i = 0; $i < 20; $i += 1 ) { $id = wp_unique_id(); - $this->assertInternalType( 'string', $id ); + $this->assertIsString( $id ); $this->assertTrue( is_numeric( $id ) ); $ids[] = $id; } diff --git a/tests/phpunit/tests/functions/wpRemoteFopen.php b/tests/phpunit/tests/functions/wpRemoteFopen.php index 3d52b82ba1be4..bee729cb3a885 100644 --- a/tests/phpunit/tests/functions/wpRemoteFopen.php +++ b/tests/phpunit/tests/functions/wpRemoteFopen.php @@ -28,7 +28,7 @@ public function test_wp_remote_fopen() { $url = 'https://asdftestblog1.files.wordpress.com/2007/09/2007-06-30-dsc_4700-1.jpg'; $response = wp_remote_fopen( $url ); - $this->assertInternalType( 'string', $response ); + $this->assertIsString( $response ); $this->assertEquals( 40148, strlen( $response ) ); } } diff --git a/tests/phpunit/tests/general/archives.php b/tests/phpunit/tests/general/archives.php index 16947902223c6..b5c5066c97421 100644 --- a/tests/phpunit/tests/general/archives.php +++ b/tests/phpunit/tests/general/archives.php @@ -29,7 +29,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $time1 = wp_cache_get( 'last_changed', 'posts' ); $this->assertNotEmpty( $time1 ); $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); @@ -43,7 +43,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries, $wpdb->num_queries ); @@ -55,7 +55,7 @@ function test_get_archives_cache() { 'order' => 'ASC', ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); @@ -69,7 +69,7 @@ function test_get_archives_cache() { 'order' => 'ASC', ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries, $wpdb->num_queries ); @@ -82,7 +82,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); @@ -95,7 +95,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries, $wpdb->num_queries ); @@ -106,7 +106,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); @@ -119,7 +119,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries, $wpdb->num_queries ); @@ -130,7 +130,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); @@ -143,7 +143,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries, $wpdb->num_queries ); @@ -154,7 +154,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries + 1, $wpdb->num_queries ); @@ -167,7 +167,7 @@ function test_get_archives_cache() { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertEquals( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertEquals( $num_queries, $wpdb->num_queries ); } diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index 42d9646a56151..30c7a8b07c607 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -290,7 +290,7 @@ function test_get_custom_logo() { $this->_set_custom_logo(); $custom_logo = get_custom_logo(); $this->assertNotEmpty( $custom_logo ); - $this->assertInternalType( 'string', $custom_logo ); + $this->assertIsString( $custom_logo ); $this->_remove_custom_logo(); $this->assertEmpty( get_custom_logo() ); diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index 16dbde78b6ea5..9b63cdfbc49aa 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -168,7 +168,7 @@ public function filter_oembed_result( $data, $url, $args ) { if ( ! is_string( $data ) && false !== $data ) { $this->fail( 'Unexpected type for $data.' ); } - $this->assertInternalType( 'string', $url ); + $this->assertIsString( $url ); $this->assertIsArray( $args ); $this->oembed_result_filter_count++; return $data; @@ -630,7 +630,7 @@ public function test_proxy_with_classic_embed_provider() { $this->assertNotEmpty( $data ); $this->assertIsObject( $data ); - $this->assertInternalType( 'string', $data->html ); + $this->assertIsString( $data->html ); $this->assertIsArray( $data->scripts ); } diff --git a/tests/phpunit/tests/post/objects.php b/tests/phpunit/tests/post/objects.php index a803e357c78d8..ee613ec634096 100644 --- a/tests/phpunit/tests/post/objects.php +++ b/tests/phpunit/tests/post/objects.php @@ -148,7 +148,7 @@ function test_get_page_template_property() { $post_id = self::factory()->post->create(); $post = get_post( $post_id ); - $this->assertInternalType( 'string', $post->page_template ); + $this->assertIsString( $post->page_template ); $template = get_post_meta( $post->ID, '_wp_page_template', true ); $this->assertEquals( $template, $post->page_template ); update_post_meta( $post_id, '_wp_page_template', 'foo.php' ); diff --git a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php index 0251aee870f89..ab5f50e3e3633 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -395,7 +395,7 @@ public function test_get_value_types() { $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_string', $meta ); - $this->assertInternalType( 'string', $meta['test_string'] ); + $this->assertIsString( $meta['test_string'] ); $this->assertSame( '42', $meta['test_string'] ); $this->assertArrayHasKey( 'test_number', $meta ); diff --git a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php index 7340dd46723f0..c9cb763b58382 100644 --- a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php @@ -342,7 +342,7 @@ public function test_get_value_types() { $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_string', $meta ); - $this->assertInternalType( 'string', $meta['test_string'] ); + $this->assertIsString( $meta['test_string'] ); $this->assertSame( '42', $meta['test_string'] ); $this->assertArrayHasKey( 'test_number', $meta ); diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index d0f136f00407f..21ad78ba2d099 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -1219,7 +1219,7 @@ public function test_create_item_invalid_username() { } else { $this->assertIsArray( $data['data']['params'] ); $errors = $data['data']['params']; - $this->assertInternalType( 'string', $errors['username'] ); + $this->assertIsString( $errors['username'] ); $this->assertEquals( 'This username is invalid because it uses illegal characters. Please enter a valid username.', $errors['username'] ); } } @@ -1259,7 +1259,7 @@ public function test_create_item_illegal_username() { $data = $response->get_data(); $this->assertIsArray( $data['data']['params'] ); $errors = $data['data']['params']; - $this->assertInternalType( 'string', $errors['username'] ); + $this->assertIsString( $errors['username'] ); $this->assertEquals( 'Sorry, that username is not allowed.', $errors['username'] ); } diff --git a/tests/phpunit/tests/term/termExists.php b/tests/phpunit/tests/term/termExists.php index d963e793ba942..2d4c533b2bc2b 100644 --- a/tests/phpunit/tests/term/termExists.php +++ b/tests/phpunit/tests/term/termExists.php @@ -234,7 +234,7 @@ public function test_term_exists_taxonomy_empty_parent_empty_match_slug() { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'string', $found ); + $this->assertIsString( $found ); $this->assertEquals( $t, $found ); } @@ -252,7 +252,7 @@ public function test_term_exists_taxonomy_empty_parent_empty_match_name() { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'string', $found ); + $this->assertIsString( $found ); $this->assertEquals( $t, $found ); } diff --git a/tests/phpunit/tests/theme/getThemeStarterContent.php b/tests/phpunit/tests/theme/getThemeStarterContent.php index 9a21027d6c99d..4cdfa6b291059 100644 --- a/tests/phpunit/tests/theme/getThemeStarterContent.php +++ b/tests/phpunit/tests/theme/getThemeStarterContent.php @@ -144,7 +144,7 @@ function test_default_content_sections() { foreach ( $hydrated_starter_content['widgets']['sidebar-1'] as $widget ) { $this->assertIsArray( $widget ); $this->assertCount( 2, $widget ); - $this->assertInternalType( 'string', $widget[0] ); + $this->assertIsString( $widget[0] ); $this->assertIsArray( $widget[1] ); $this->assertArrayHasKey( 'title', $widget[1] ); } @@ -158,7 +158,7 @@ function test_default_content_sections() { $this->assertEquals( 'Email Us', $hydrated_starter_content['nav_menus']['top']['items'][4]['title'], 'Core content extended' ); foreach ( $hydrated_starter_content['posts'] as $key => $post ) { - $this->assertInternalType( 'string', $key ); + $this->assertIsString( $key ); $this->assertFalse( is_numeric( $key ) ); $this->assertIsArray( $post ); $this->assertArrayHasKey( 'post_type', $post ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php index bd015319100c6..8478e38d52412 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/getPost.php @@ -52,26 +52,26 @@ function test_valid_post() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['userid'] ); + $this->assertIsString( $result['userid'] ); $this->assertIsInt( $result['postid'] ); - $this->assertInternalType( 'string', $result['description'] ); - $this->assertInternalType( 'string', $result['title'] ); - $this->assertInternalType( 'string', $result['link'] ); - $this->assertInternalType( 'string', $result['permaLink'] ); + $this->assertIsString( $result['description'] ); + $this->assertIsString( $result['title'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['permaLink'] ); $this->assertIsArray( $result['categories'] ); - $this->assertInternalType( 'string', $result['mt_excerpt'] ); - $this->assertInternalType( 'string', $result['mt_text_more'] ); - $this->assertInternalType( 'string', $result['wp_more_text'] ); + $this->assertIsString( $result['mt_excerpt'] ); + $this->assertIsString( $result['mt_text_more'] ); + $this->assertIsString( $result['wp_more_text'] ); $this->assertIsInt( $result['mt_allow_comments'] ); $this->assertIsInt( $result['mt_allow_pings'] ); - $this->assertInternalType( 'string', $result['mt_keywords'] ); - $this->assertInternalType( 'string', $result['wp_slug'] ); - $this->assertInternalType( 'string', $result['wp_password'] ); - $this->assertInternalType( 'string', $result['wp_author_id'] ); - $this->assertInternalType( 'string', $result['wp_author_display_name'] ); - $this->assertInternalType( 'string', $result['post_status'] ); + $this->assertIsString( $result['mt_keywords'] ); + $this->assertIsString( $result['wp_slug'] ); + $this->assertIsString( $result['wp_password'] ); + $this->assertIsString( $result['wp_author_id'] ); + $this->assertIsString( $result['wp_author_display_name'] ); + $this->assertIsString( $result['post_status'] ); $this->assertIsArray( $result['custom_fields'] ); - $this->assertInternalType( 'string', $result['wp_post_format'] ); + $this->assertIsString( $result['wp_post_format'] ); $this->assertIsBool( $result['sticky'] ); $post_data = get_post( self::$post_id ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php index 4513bdd1e7046..fcd819f232f3a 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php +++ b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php @@ -58,26 +58,26 @@ function test_valid_post() { $post = get_post( $result['postid'] ); // Check data types. - $this->assertInternalType( 'string', $result['userid'] ); - $this->assertInternalType( 'string', $result['postid'] ); - $this->assertInternalType( 'string', $result['description'] ); - $this->assertInternalType( 'string', $result['title'] ); - $this->assertInternalType( 'string', $result['link'] ); - $this->assertInternalType( 'string', $result['permaLink'] ); + $this->assertIsString( $result['userid'] ); + $this->assertIsString( $result['postid'] ); + $this->assertIsString( $result['description'] ); + $this->assertIsString( $result['title'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['permaLink'] ); $this->assertIsArray( $result['categories'] ); - $this->assertInternalType( 'string', $result['mt_excerpt'] ); - $this->assertInternalType( 'string', $result['mt_text_more'] ); - $this->assertInternalType( 'string', $result['wp_more_text'] ); + $this->assertIsString( $result['mt_excerpt'] ); + $this->assertIsString( $result['mt_text_more'] ); + $this->assertIsString( $result['wp_more_text'] ); $this->assertIsInt( $result['mt_allow_comments'] ); $this->assertIsInt( $result['mt_allow_pings'] ); - $this->assertInternalType( 'string', $result['mt_keywords'] ); - $this->assertInternalType( 'string', $result['wp_slug'] ); - $this->assertInternalType( 'string', $result['wp_password'] ); - $this->assertInternalType( 'string', $result['wp_author_id'] ); - $this->assertInternalType( 'string', $result['wp_author_display_name'] ); - $this->assertInternalType( 'string', $result['post_status'] ); + $this->assertIsString( $result['mt_keywords'] ); + $this->assertIsString( $result['wp_slug'] ); + $this->assertIsString( $result['wp_password'] ); + $this->assertIsString( $result['wp_author_id'] ); + $this->assertIsString( $result['wp_author_display_name'] ); + $this->assertIsString( $result['post_status'] ); $this->assertIsArray( $result['custom_fields'] ); - $this->assertInternalType( 'string', $result['wp_post_format'] ); + $this->assertIsString( $result['wp_post_format'] ); // Check expected values. $this->assertStringMatchesFormat( '%d', $result['userid'] ); @@ -106,7 +106,7 @@ function test_post_thumbnail() { $this->assertNotIXRError( $results ); foreach ( $results as $result ) { - $this->assertInternalType( 'string', $result['wp_post_thumbnail'] ); + $this->assertIsString( $result['wp_post_thumbnail'] ); $this->assertStringMatchesFormat( '%d', $result['wp_post_thumbnail'] ); if ( ! empty( $result['wp_post_thumbnail'] ) || $result['postid'] === self::$post_id ) { diff --git a/tests/phpunit/tests/xmlrpc/wp/getComment.php b/tests/phpunit/tests/xmlrpc/wp/getComment.php index 0c6b49d1a5a24..72d735249e65a 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComment.php @@ -54,20 +54,20 @@ function test_valid_comment() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['user_id'] ); - $this->assertInternalType( 'string', $result['comment_id'] ); + $this->assertIsString( $result['user_id'] ); + $this->assertIsString( $result['comment_id'] ); $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); - $this->assertInternalType( 'string', $result['parent'] ); - $this->assertInternalType( 'string', $result['status'] ); - $this->assertInternalType( 'string', $result['content'] ); - $this->assertInternalType( 'string', $result['link'] ); - $this->assertInternalType( 'string', $result['post_id'] ); - $this->assertInternalType( 'string', $result['post_title'] ); - $this->assertInternalType( 'string', $result['author'] ); - $this->assertInternalType( 'string', $result['author_url'] ); - $this->assertInternalType( 'string', $result['author_email'] ); - $this->assertInternalType( 'string', $result['author_ip'] ); - $this->assertInternalType( 'string', $result['type'] ); + $this->assertIsString( $result['parent'] ); + $this->assertIsString( $result['status'] ); + $this->assertIsString( $result['content'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['post_id'] ); + $this->assertIsString( $result['post_title'] ); + $this->assertIsString( $result['author'] ); + $this->assertIsString( $result['author_url'] ); + $this->assertIsString( $result['author_email'] ); + $this->assertIsString( $result['author_ip'] ); + $this->assertIsString( $result['type'] ); // Check expected values. $this->assertStringMatchesFormat( '%d', $result['user_id'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php index 7f1b4f894d547..87ea698e4a160 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php +++ b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php @@ -50,14 +50,14 @@ function test_valid_media_item() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['attachment_id'] ); + $this->assertIsString( $result['attachment_id'] ); $this->assertIsInt( $result['parent'] ); - $this->assertInternalType( 'string', $result['title'] ); + $this->assertIsString( $result['title'] ); $this->assertInstanceOf( 'IXR_Date', $result['date_created_gmt'] ); - $this->assertInternalType( 'string', $result['caption'] ); - $this->assertInternalType( 'string', $result['description'] ); - $this->assertInternalType( 'string', $result['link'] ); - $this->assertInternalType( 'string', $result['thumbnail'] ); + $this->assertIsString( $result['caption'] ); + $this->assertIsString( $result['description'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['thumbnail'] ); $this->assertIsArray( $result['metadata'] ); // Check expected values. diff --git a/tests/phpunit/tests/xmlrpc/wp/getPage.php b/tests/phpunit/tests/xmlrpc/wp/getPage.php index 9a8eae0d45d46..3a00bf0be42bd 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPage.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPage.php @@ -46,28 +46,28 @@ function test_valid_page() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['userid'] ); + $this->assertIsString( $result['userid'] ); $this->assertIsInt( $result['page_id'] ); - $this->assertInternalType( 'string', $result['page_status'] ); - $this->assertInternalType( 'string', $result['description'] ); - $this->assertInternalType( 'string', $result['title'] ); - $this->assertInternalType( 'string', $result['link'] ); - $this->assertInternalType( 'string', $result['permaLink'] ); + $this->assertIsString( $result['page_status'] ); + $this->assertIsString( $result['description'] ); + $this->assertIsString( $result['title'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['permaLink'] ); $this->assertIsArray( $result['categories'] ); - $this->assertInternalType( 'string', $result['excerpt'] ); - $this->assertInternalType( 'string', $result['text_more'] ); + $this->assertIsString( $result['excerpt'] ); + $this->assertIsString( $result['text_more'] ); $this->assertIsInt( $result['mt_allow_comments'] ); $this->assertIsInt( $result['mt_allow_pings'] ); - $this->assertInternalType( 'string', $result['wp_slug'] ); - $this->assertInternalType( 'string', $result['wp_password'] ); - $this->assertInternalType( 'string', $result['wp_author'] ); + $this->assertIsString( $result['wp_slug'] ); + $this->assertIsString( $result['wp_password'] ); + $this->assertIsString( $result['wp_author'] ); $this->assertIsInt( $result['wp_page_parent_id'] ); - $this->assertInternalType( 'string', $result['wp_page_parent_title'] ); + $this->assertIsString( $result['wp_page_parent_title'] ); $this->assertIsInt( $result['wp_page_order'] ); - $this->assertInternalType( 'string', $result['wp_author_id'] ); - $this->assertInternalType( 'string', $result['wp_author_display_name'] ); + $this->assertIsString( $result['wp_author_id'] ); + $this->assertIsString( $result['wp_author_display_name'] ); $this->assertIsArray( $result['custom_fields'] ); - $this->assertInternalType( 'string', $result['wp_page_template'] ); + $this->assertIsString( $result['wp_page_template'] ); $post_data = get_post( self::$post_id ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php index d807c78cbf84b..30ec90937d590 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -42,24 +42,24 @@ function test_valid_post() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['post_id'] ); - $this->assertInternalType( 'string', $result['post_title'] ); + $this->assertIsString( $result['post_id'] ); + $this->assertIsString( $result['post_title'] ); $this->assertInstanceOf( 'IXR_Date', $result['post_date'] ); $this->assertInstanceOf( 'IXR_Date', $result['post_date_gmt'] ); $this->assertInstanceOf( 'IXR_Date', $result['post_modified'] ); $this->assertInstanceOf( 'IXR_Date', $result['post_modified_gmt'] ); - $this->assertInternalType( 'string', $result['post_status'] ); - $this->assertInternalType( 'string', $result['post_type'] ); - $this->assertInternalType( 'string', $result['post_name'] ); - $this->assertInternalType( 'string', $result['post_author'] ); - $this->assertInternalType( 'string', $result['post_password'] ); - $this->assertInternalType( 'string', $result['post_excerpt'] ); - $this->assertInternalType( 'string', $result['post_content'] ); - $this->assertInternalType( 'string', $result['link'] ); - $this->assertInternalType( 'string', $result['comment_status'] ); - $this->assertInternalType( 'string', $result['ping_status'] ); + $this->assertIsString( $result['post_status'] ); + $this->assertIsString( $result['post_type'] ); + $this->assertIsString( $result['post_name'] ); + $this->assertIsString( $result['post_author'] ); + $this->assertIsString( $result['post_password'] ); + $this->assertIsString( $result['post_excerpt'] ); + $this->assertIsString( $result['post_content'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['comment_status'] ); + $this->assertIsString( $result['ping_status'] ); $this->assertIsBool( $result['sticky'] ); - $this->assertInternalType( 'string', $result['post_format'] ); + $this->assertIsString( $result['post_format'] ); $this->assertIsArray( $result['post_thumbnail'] ); $this->assertIsArray( $result['custom_fields'] ); @@ -137,11 +137,11 @@ function test_valid_page() { $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'editor', 'editor', $child_page_id ) ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'string', $result['post_id'] ); - $this->assertInternalType( 'string', $result['post_parent'] ); + $this->assertIsString( $result['post_id'] ); + $this->assertIsString( $result['post_parent'] ); $this->assertIsInt( $result['menu_order'] ); - $this->assertInternalType( 'string', $result['guid'] ); - $this->assertInternalType( 'string', $result['post_mime_type'] ); + $this->assertIsString( $result['guid'] ); + $this->assertIsString( $result['post_mime_type'] ); $this->assertEquals( 'page', $result['post_type'] ); $this->assertEquals( $parent_page_id, $result['post_parent'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostType.php b/tests/phpunit/tests/xmlrpc/wp/getPostType.php index 335c0eda64f8e..b2d7e7d51cfde 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostType.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostType.php @@ -65,8 +65,8 @@ function test_valid_type() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['name'] ); - $this->assertInternalType( 'string', $result['label'] ); + $this->assertIsString( $result['name'] ); + $this->assertIsString( $result['label'] ); $this->assertIsBool( $result['hierarchical'] ); $this->assertIsBool( $result['public'] ); $this->assertIsBool( $result['_builtin'] ); @@ -74,52 +74,52 @@ function test_valid_type() { $this->assertIsBool( $result['has_archive'] ); $this->assertIsBool( $result['show_ui'] ); $this->assertIsInt( $result['menu_position'] ); - $this->assertInternalType( 'string', $result['menu_icon'] ); + $this->assertIsString( $result['menu_icon'] ); $this->assertIsArray( $result['labels'] ); $this->assertIsArray( $result['cap'] ); $this->assertIsArray( $result['taxonomies'] ); $this->assertIsArray( $result['supports'] ); // Check label data types. - $this->assertInternalType( 'string', $result['labels']['name'] ); - $this->assertInternalType( 'string', $result['labels']['singular_name'] ); - $this->assertInternalType( 'string', $result['labels']['add_new'] ); - $this->assertInternalType( 'string', $result['labels']['add_new_item'] ); - $this->assertInternalType( 'string', $result['labels']['edit_item'] ); - $this->assertInternalType( 'string', $result['labels']['new_item'] ); - $this->assertInternalType( 'string', $result['labels']['view_item'] ); - $this->assertInternalType( 'string', $result['labels']['search_items'] ); - $this->assertInternalType( 'string', $result['labels']['not_found'] ); - $this->assertInternalType( 'string', $result['labels']['not_found_in_trash'] ); - $this->assertInternalType( 'string', $result['labels']['parent_item_colon'] ); - $this->assertInternalType( 'string', $result['labels']['all_items'] ); - $this->assertInternalType( 'string', $result['labels']['menu_name'] ); - $this->assertInternalType( 'string', $result['labels']['name_admin_bar'] ); + $this->assertIsString( $result['labels']['name'] ); + $this->assertIsString( $result['labels']['singular_name'] ); + $this->assertIsString( $result['labels']['add_new'] ); + $this->assertIsString( $result['labels']['add_new_item'] ); + $this->assertIsString( $result['labels']['edit_item'] ); + $this->assertIsString( $result['labels']['new_item'] ); + $this->assertIsString( $result['labels']['view_item'] ); + $this->assertIsString( $result['labels']['search_items'] ); + $this->assertIsString( $result['labels']['not_found'] ); + $this->assertIsString( $result['labels']['not_found_in_trash'] ); + $this->assertIsString( $result['labels']['parent_item_colon'] ); + $this->assertIsString( $result['labels']['all_items'] ); + $this->assertIsString( $result['labels']['menu_name'] ); + $this->assertIsString( $result['labels']['name_admin_bar'] ); // Check cap data types. - $this->assertInternalType( 'string', $result['cap']['edit_post'] ); - $this->assertInternalType( 'string', $result['cap']['read_post'] ); - $this->assertInternalType( 'string', $result['cap']['delete_post'] ); - $this->assertInternalType( 'string', $result['cap']['edit_posts'] ); - $this->assertInternalType( 'string', $result['cap']['edit_others_posts'] ); - $this->assertInternalType( 'string', $result['cap']['publish_posts'] ); - $this->assertInternalType( 'string', $result['cap']['read_private_posts'] ); - $this->assertInternalType( 'string', $result['cap']['read'] ); - $this->assertInternalType( 'string', $result['cap']['delete_posts'] ); - $this->assertInternalType( 'string', $result['cap']['delete_private_posts'] ); - $this->assertInternalType( 'string', $result['cap']['delete_published_posts'] ); - $this->assertInternalType( 'string', $result['cap']['delete_others_posts'] ); - $this->assertInternalType( 'string', $result['cap']['edit_private_posts'] ); - $this->assertInternalType( 'string', $result['cap']['edit_published_posts'] ); + $this->assertIsString( $result['cap']['edit_post'] ); + $this->assertIsString( $result['cap']['read_post'] ); + $this->assertIsString( $result['cap']['delete_post'] ); + $this->assertIsString( $result['cap']['edit_posts'] ); + $this->assertIsString( $result['cap']['edit_others_posts'] ); + $this->assertIsString( $result['cap']['publish_posts'] ); + $this->assertIsString( $result['cap']['read_private_posts'] ); + $this->assertIsString( $result['cap']['read'] ); + $this->assertIsString( $result['cap']['delete_posts'] ); + $this->assertIsString( $result['cap']['delete_private_posts'] ); + $this->assertIsString( $result['cap']['delete_published_posts'] ); + $this->assertIsString( $result['cap']['delete_others_posts'] ); + $this->assertIsString( $result['cap']['edit_private_posts'] ); + $this->assertIsString( $result['cap']['edit_published_posts'] ); // Check taxonomy data types. foreach ( $result['taxonomies'] as $taxonomy ) { - $this->assertInternalType( 'string', $taxonomy ); + $this->assertIsString( $taxonomy ); } // Check support data types. foreach ( $result['supports'] as $key => $value ) { - $this->assertInternalType( 'string', $key ); + $this->assertIsString( $key ); $this->assertIsBool( $value ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerm.php b/tests/phpunit/tests/xmlrpc/wp/getTerm.php index ec11a70effbb9..2b29146194d8b 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerm.php @@ -79,10 +79,10 @@ function test_valid_term() { $this->assertEquals( $result, $term ); // Check data types. - $this->assertInternalType( 'string', $result['name'] ); - $this->assertInternalType( 'string', $result['slug'] ); - $this->assertInternalType( 'string', $result['taxonomy'] ); - $this->assertInternalType( 'string', $result['description'] ); + $this->assertIsString( $result['name'] ); + $this->assertIsString( $result['slug'] ); + $this->assertIsString( $result['taxonomy'] ); + $this->assertIsString( $result['description'] ); $this->assertIsInt( $result['count'] ); // We expect all ID's to be strings not integers so we don't return something larger than an XMLRPC integer can describe. diff --git a/tests/phpunit/tests/xmlrpc/wp/getUser.php b/tests/phpunit/tests/xmlrpc/wp/getUser.php index bbb94e32f612a..bde08fbaea6b9 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUser.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUser.php @@ -76,18 +76,18 @@ function test_valid_user() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['user_id'] ); + $this->assertIsString( $result['user_id'] ); $this->assertStringMatchesFormat( '%d', $result['user_id'] ); - $this->assertInternalType( 'string', $result['username'] ); - $this->assertInternalType( 'string', $result['first_name'] ); - $this->assertInternalType( 'string', $result['last_name'] ); + $this->assertIsString( $result['username'] ); + $this->assertIsString( $result['first_name'] ); + $this->assertIsString( $result['last_name'] ); $this->assertInstanceOf( 'IXR_Date', $result['registered'] ); - $this->assertInternalType( 'string', $result['bio'] ); - $this->assertInternalType( 'string', $result['email'] ); - $this->assertInternalType( 'string', $result['nickname'] ); - $this->assertInternalType( 'string', $result['nicename'] ); - $this->assertInternalType( 'string', $result['url'] ); - $this->assertInternalType( 'string', $result['display_name'] ); + $this->assertIsString( $result['bio'] ); + $this->assertIsString( $result['email'] ); + $this->assertIsString( $result['nickname'] ); + $this->assertIsString( $result['nicename'] ); + $this->assertIsString( $result['url'] ); + $this->assertIsString( $result['display_name'] ); $this->assertIsArray( $result['roles'] ); // Check expected values. diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php index 34ab25f3550dd..8de90e7eeb8a4 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php @@ -27,18 +27,18 @@ function test_capable_user() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result[0]['user_id'] ); + $this->assertIsString( $result[0]['user_id'] ); $this->assertStringMatchesFormat( '%d', $result[0]['user_id'] ); - $this->assertInternalType( 'string', $result[0]['username'] ); - $this->assertInternalType( 'string', $result[0]['first_name'] ); - $this->assertInternalType( 'string', $result[0]['last_name'] ); + $this->assertIsString( $result[0]['username'] ); + $this->assertIsString( $result[0]['first_name'] ); + $this->assertIsString( $result[0]['last_name'] ); $this->assertInstanceOf( 'IXR_Date', $result[0]['registered'] ); - $this->assertInternalType( 'string', $result[0]['bio'] ); - $this->assertInternalType( 'string', $result[0]['email'] ); - $this->assertInternalType( 'string', $result[0]['nickname'] ); - $this->assertInternalType( 'string', $result[0]['nicename'] ); - $this->assertInternalType( 'string', $result[0]['url'] ); - $this->assertInternalType( 'string', $result[0]['display_name'] ); + $this->assertIsString( $result[0]['bio'] ); + $this->assertIsString( $result[0]['email'] ); + $this->assertIsString( $result[0]['nickname'] ); + $this->assertIsString( $result[0]['nicename'] ); + $this->assertIsString( $result[0]['url'] ); + $this->assertIsString( $result[0]['display_name'] ); $this->assertIsArray( $result[0]['roles'] ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php index 37a28149e3fff..96a0033e91c6f 100644 --- a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php +++ b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php @@ -27,10 +27,10 @@ function test_valid_attachment() { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['id'] ); + $this->assertIsString( $result['id'] ); $this->assertStringMatchesFormat( '%d', $result['id'] ); - $this->assertInternalType( 'string', $result['file'] ); - $this->assertInternalType( 'string', $result['url'] ); - $this->assertInternalType( 'string', $result['type'] ); + $this->assertIsString( $result['file'] ); + $this->assertIsString( $result['url'] ); + $this->assertIsString( $result['type'] ); } }