diff --git a/tests/phpunit/includes/testcase.php b/tests/phpunit/includes/testcase.php index 019606c686..b2dd743e24 100644 --- a/tests/phpunit/includes/testcase.php +++ b/tests/phpunit/includes/testcase.php @@ -32,4 +32,344 @@ class WP_UnitTestCase extends WP_UnitTestCase_Base { public static function assertEqualsWithDelta( $expected, $actual, $delta, $message = '' ) { static::assertEquals( $expected, $actual, $message, $delta ); } + + /** + * Asserts that a variable is of type array. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsArray( $actual, $message = '' ) { + static::assertInternalType( 'array', $actual, $message ); + } + + /** + * Asserts that a variable is of type bool. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsBool( $actual, $message = '' ) { + static::assertInternalType( 'bool', $actual, $message ); + } + + /** + * Asserts that a variable is of type float. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsFloat( $actual, $message = '' ) { + static::assertInternalType( 'float', $actual, $message ); + } + + /** + * Asserts that a variable is of type int. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsInt( $actual, $message = '' ) { + static::assertInternalType( 'int', $actual, $message ); + } + + /** + * Asserts that a variable is of type numeric. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNumeric( $actual, $message = '' ) { + static::assertInternalType( 'numeric', $actual, $message ); + } + + /** + * Asserts that a variable is of type object. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsObject( $actual, $message = '' ) { + static::assertInternalType( 'object', $actual, $message ); + } + + /** + * Asserts that a variable is of type resource. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsResource( $actual, $message = '' ) { + static::assertInternalType( 'resource', $actual, $message ); + } + + /** + * Asserts that a variable is of type string. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsString( $actual, $message = '' ) { + static::assertInternalType( 'string', $actual, $message ); + } + + /** + * Asserts that a variable is of type scalar. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsScalar( $actual, $message = '' ) { + static::assertInternalType( 'scalar', $actual, $message ); + } + + /** + * Asserts that a variable is of type callable. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsCallable( $actual, $message = '' ) { + static::assertInternalType( 'callable', $actual, $message ); + } + + /** + * Asserts that a variable is of type iterable. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * Support for `iterable` was only added to `Assert::assertNotInternalType()` + * in PHPUnit 7.1.0, so this polyfill cannot use a direct fall-through + * to that functionality until WordPress test suite requires PHPUnit 7.1.0 + * as the minimum version. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsIterable( $actual, $message = '' ) { + static::assertTrue( is_iterable( $actual ), $message ); + } + + /** + * Asserts that a variable is not of type array. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotArray( $actual, $message = '' ) { + static::assertNotInternalType( 'array', $actual, $message ); + } + + /** + * Asserts that a variable is not of type bool. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotBool( $actual, $message = '' ) { + static::assertNotInternalType( 'bool', $actual, $message ); + } + + /** + * Asserts that a variable is not of type float. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotFloat( $actual, $message = '' ) { + static::assertNotInternalType( 'float', $actual, $message ); + } + + /** + * Asserts that a variable is not of type int. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotInt( $actual, $message = '' ) { + static::assertNotInternalType( 'int', $actual, $message ); + } + + /** + * Asserts that a variable is not of type numeric. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotNumeric( $actual, $message = '' ) { + static::assertNotInternalType( 'numeric', $actual, $message ); + } + + /** + * Asserts that a variable is not of type object. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotObject( $actual, $message = '' ) { + static::assertNotInternalType( 'object', $actual, $message ); + } + + /** + * Asserts that a variable is not of type resource. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotResource( $actual, $message = '' ) { + static::assertNotInternalType( 'resource', $actual, $message ); + } + + /** + * Asserts that a variable is not of type string. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotString( $actual, $message = '' ) { + static::assertNotInternalType( 'string', $actual, $message ); + } + + /** + * Asserts that a variable is not of type scalar. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotScalar( $actual, $message = '' ) { + static::assertNotInternalType( 'scalar', $actual, $message ); + } + + /** + * Asserts that a variable is not of type callable. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotCallable( $actual, $message = '' ) { + static::assertNotInternalType( 'callable', $actual, $message ); + } + + /** + * Asserts that a variable is not of type iterable. + * + * This method has been backported from a more recent PHPUnit version, + * as tests running on PHP 5.6 use PHPUnit 5.7.x. + * + * Support for `iterable` was only added to `Assert::assertNotInternalType()` + * in PHPUnit 7.1.0, so this polyfill cannot use a direct fall-through + * to that functionality until WordPress test suite requires PHPUnit 7.1.0 + * as the minimum version. + * + * @since 5.9.0 + * + * @param mixed $actual The value to check. + * @param string $message Optional. Message to display when the assertion fails. + */ + public static function assertIsNotIterable( $actual, $message = '' ) { + static::assertFalse( is_iterable( $actual ), $message ); + } } diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index 2004e30ae3..68f8daddbd 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -166,7 +166,7 @@ class Tests_AdminBar extends WP_UnitTestCase { // Get primary blog. $primary = get_active_blog_for_user( self::$editor_id ); - $this->assertInternalType( 'object', $primary ); + $this->assertIsObject( $primary ); // No Site menu as the user isn't a member of this blog. $this->assertNull( $node_site_name ); diff --git a/tests/phpunit/tests/ajax/CustomizeManager.php b/tests/phpunit/tests/ajax/CustomizeManager.php index b5ad859702..d6ce045da2 100644 --- a/tests/phpunit/tests/ajax/CustomizeManager.php +++ b/tests/phpunit/tests/ajax/CustomizeManager.php @@ -286,7 +286,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { ); $this->make_ajax_call( 'customize_save' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertInternalType( 'array', $this->_last_response_parsed['data'] ); + $this->assertIsArray( $this->_last_response_parsed['data'] ); $this->assertSame( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); @@ -325,7 +325,7 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase { $_POST['customize_changeset_title'] = 'Published'; $this->make_ajax_call( 'customize_save' ); $this->assertTrue( $this->_last_response_parsed['success'] ); - $this->assertInternalType( 'array', $this->_last_response_parsed['data'] ); + $this->assertIsArray( $this->_last_response_parsed['data'] ); $this->assertSame( 'publish', $this->_last_response_parsed['data']['changeset_status'] ); $this->assertArrayHasKey( 'next_changeset_uuid', $this->_last_response_parsed['data'] ); diff --git a/tests/phpunit/tests/blocks/block-editor.php b/tests/phpunit/tests/blocks/block-editor.php index 42166be6da..4d4fe7b3b5 100644 --- a/tests/phpunit/tests/blocks/block-editor.php +++ b/tests/phpunit/tests/blocks/block-editor.php @@ -172,7 +172,7 @@ class WP_Test_Block_Editor extends WP_UnitTestCase { $this->assertCount( 16, $settings ); $this->assertFalse( $settings['alignWide'] ); - $this->assertInternalType( 'array', $settings['allowedMimeTypes'] ); + $this->assertIsArray( $settings['allowedMimeTypes'] ); $this->assertTrue( $settings['allowedBlockTypes'] ); $this->assertSameSets( array( @@ -264,7 +264,7 @@ class WP_Test_Block_Editor extends WP_UnitTestCase { ), $settings['imageSizes'] ); - $this->assertInternalType( 'int', $settings['maxUploadFileSize'] ); + $this->assertIsInt( $settings['maxUploadFileSize'] ); } /** diff --git a/tests/phpunit/tests/blocks/render.php b/tests/phpunit/tests/blocks/render.php index aa9cf7cf65..b22b8495db 100644 --- a/tests/phpunit/tests/blocks/render.php +++ b/tests/phpunit/tests/blocks/render.php @@ -324,7 +324,7 @@ class WP_Test_Block_Render extends WP_UnitTestCase { $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/bookmark/getBookmark.php b/tests/phpunit/tests/bookmark/getBookmark.php index 93e6ddf189..f9d69dc141 100644 --- a/tests/phpunit/tests/bookmark/getBookmark.php +++ b/tests/phpunit/tests/bookmark/getBookmark.php @@ -349,8 +349,8 @@ class Tests_Bookmark_GetBookmark extends WP_UnitTestCase { foreach ( $contexts as $context ) { $bookmark = get_bookmark( self::$bookmark->link_id, OBJECT, $context ); - $this->assertInternalType( 'int', $bookmark->link_id ); - $this->assertInternalType( 'int', $bookmark->link_rating ); + $this->assertIsInt( $bookmark->link_id ); + $this->assertIsInt( $bookmark->link_rating ); } } diff --git a/tests/phpunit/tests/comment/metaCache.php b/tests/phpunit/tests/comment/metaCache.php index a455654e11..bcfd6b5fdb 100644 --- a/tests/phpunit/tests/comment/metaCache.php +++ b/tests/phpunit/tests/comment/metaCache.php @@ -233,7 +233,7 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { wp_cache_delete( 'last_changed', 'comment' ); - $this->assertInternalType( 'integer', add_metadata( 'comment', $comment_id, 'foo', 'bar' ) ); + $this->assertIsInt( add_metadata( 'comment', $comment_id, 'foo', 'bar' ) ); $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) ); } @@ -245,7 +245,7 @@ class Tests_Comment_Meta_Cache extends WP_UnitTestCase { wp_cache_delete( 'last_changed', 'comment' ); - $this->assertInternalType( 'integer', update_metadata( 'comment', $comment_id, 'foo', 'bar' ) ); + $this->assertIsInt( update_metadata( 'comment', $comment_id, 'foo', 'bar' ) ); $this->assertNotFalse( wp_cache_get_last_changed( 'comment' ) ); } diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index e0dc8879e7..8b5a523a40 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -1713,9 +1713,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { ); // Ensure we are dealing with integers, and not objects. - $this->assertInternalType( 'integer', $comment_1 ); - $this->assertInternalType( 'integer', $comment_2 ); - $this->assertInternalType( 'integer', $comment_3 ); + $this->assertIsInt( $comment_1 ); + $this->assertIsInt( $comment_2 ); + $this->assertIsInt( $comment_3 ); $comment_ids = get_comments( array( 'fields' => 'ids' ) ); $this->assertCount( 3, $comment_ids ); @@ -3331,9 +3331,9 @@ class Tests_Comment_Query extends WP_UnitTestCase { $this->assertNull( $query1->query_vars ); $this->assertEmpty( $query1->comments ); $comments = $query1->query( array( 'status' => 'all' ) ); - $this->assertInternalType( 'array', $query1->query_vars ); + $this->assertIsArray( $query1->query_vars ); $this->assertNotEmpty( $query1->comments ); - $this->assertInternalType( 'array', $query1->comments ); + $this->assertIsArray( $query1->comments ); $query2 = new WP_Comment_Query( array( 'status' => 'all' ) ); $this->assertNotEmpty( $query2->query_vars ); diff --git a/tests/phpunit/tests/customize/custom-css-setting.php b/tests/phpunit/tests/customize/custom-css-setting.php index 43fb1111d2..c1d9df7cd6 100644 --- a/tests/phpunit/tests/customize/custom-css-setting.php +++ b/tests/phpunit/tests/customize/custom-css-setting.php @@ -344,10 +344,10 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { * @return array Data. */ function filter_update_custom_css_data( $data, $args ) { - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertSameSets( array( 'css', 'preprocessed' ), array_keys( $data ) ); $this->assertSame( '', $data['preprocessed'] ); - $this->assertInternalType( 'array', $args ); + $this->assertIsArray( $args ); $this->assertSameSets( array( 'css', 'preprocessed', 'stylesheet' ), array_keys( $args ) ); $this->assertSame( $args['css'], $data['css'] ); $this->assertSame( $args['preprocessed'], $data['preprocessed'] ); diff --git a/tests/phpunit/tests/customize/manager.php b/tests/phpunit/tests/customize/manager.php index d8918b81b1..a2a0365f24 100644 --- a/tests/phpunit/tests/customize/manager.php +++ b/tests/phpunit/tests/customize/manager.php @@ -677,9 +677,9 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { $this->assertSameSets( $expected_setting_ids, array_keys( $changeset_values ) ); foreach ( array( 'widget_text[2]', 'widget_meta[2]' ) as $setting_id ) { - $this->assertInternalType( 'array', $changeset_values[ $setting_id ] ); + $this->assertIsArray( $changeset_values[ $setting_id ] ); $instance_data = $wp_customize->widgets->sanitize_widget_instance( $changeset_values[ $setting_id ] ); - $this->assertInternalType( 'array', $instance_data ); + $this->assertIsArray( $instance_data ); $this->assertArrayHasKey( 'title', $instance_data ); } @@ -731,7 +731,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { $this->assertNull( $wp_customize->changeset_post_id() ); $this->assertSame( 1000, has_action( 'customize_register', array( $wp_customize, '_save_starter_content_changeset' ) ) ); do_action( 'customize_register', $wp_customize ); // This will trigger the changeset save. - $this->assertInternalType( 'int', $wp_customize->changeset_post_id() ); + $this->assertIsInt( $wp_customize->changeset_post_id() ); $this->assertNotEmpty( $wp_customize->changeset_data() ); foreach ( $wp_customize->changeset_data() as $setting_id => $setting_params ) { $this->assertArrayHasKey( 'starter_content', $setting_params ); @@ -787,7 +787,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { $this->assertSame( 'auto-draft', get_post( $posts_by_name['waffles'] )->post_status ); $this->assertNotEquals( $changeset_data['blogname']['value'], get_option( 'blogname' ) ); $r = $wp_customize->save_changeset_post( array( 'status' => 'publish' ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); $this->assertSame( 'publish', get_post( $posts_by_name['about'] )->post_status ); $this->assertSame( 'inherit', get_post( $posts_by_name['waffles'] )->post_status ); $this->assertSame( $changeset_data['blogname']['value'], get_option( 'blogname' ) ); @@ -1041,7 +1041,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { 'data' => $pre_saved_data, ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); $this->assertSame( $did_action['customize_save_validation_before'] + 1, did_action( 'customize_save_validation_before' ) ); @@ -1098,7 +1098,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { ); $this->assertInstanceOf( 'WP_Error', $r ); $this->assertSame( 'transaction_fail', $r->get_error_code() ); - $this->assertInternalType( 'array', $r->get_error_data() ); + $this->assertIsArray( $r->get_error_data() ); $this->assertArrayHasKey( 'setting_validities', $r->get_error_data() ); $error_data = $r->get_error_data(); $this->assertArrayHasKey( 'blogname', $error_data['setting_validities'] ); @@ -1137,7 +1137,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { ), ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); $this->assertArrayHasKey( 'setting_validities', $r ); $this->assertTrue( $r['setting_validities']['blogname'] ); $this->assertInstanceOf( 'WP_Error', $r['setting_validities']['bar_unknown'] ); @@ -1205,7 +1205,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { ), ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); $this->assertSame( 'Do it live \o/', get_option( 'blogname' ) ); $this->assertSame( 'trash', get_post_status( $post_id ) ); // Auto-trashed. $this->assertSame( $original_capabilities, wp_list_pluck( $manager->settings(), 'capability' ) ); @@ -1422,8 +1422,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { */ function filter_customize_changeset_save_data( $data, $context ) { $this->customize_changeset_save_data_call_count += 1; - $this->assertInternalType( 'array', $data ); - $this->assertInternalType( 'array', $context ); + $this->assertIsArray( $data ); + $this->assertIsArray( $context ); $this->assertArrayHasKey( 'uuid', $context ); $this->assertArrayHasKey( 'title', $context ); $this->assertArrayHasKey( 'status', $context ); @@ -1513,7 +1513,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { ), ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); $this->assertSame( array_fill_keys( array( 'blogname', 'scratchpad', 'background_color' ), true ), $r['setting_validities'] @@ -1540,7 +1540,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { ), ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); $this->assertSame( array_fill_keys( array( 'blogname', 'background_color' ), true ), $r['setting_validities'] @@ -1569,7 +1569,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { 'user_id' => self::$subscriber_user_id, ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); $this->assertSame( array_fill_keys( array( 'blogname', 'scratchpad' ), true ), $r['setting_validities'] @@ -1888,7 +1888,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { 'autosave' => true, ) ); - $this->assertInternalType( 'array', $r ); + $this->assertIsArray( $r ); // Verify that autosave happened. $autosave_revision = wp_get_post_autosave( $changeset_post_id, get_current_user_id() ); @@ -2715,10 +2715,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { $error->add( 'bad_letter', 'Bad letra', 123 ); $error->add( 'bad_number', 'Bad number', array( 'number' => 123 ) ); $validity = $this->manager->prepare_setting_validity_for_js( $error ); - $this->assertInternalType( 'array', $validity ); + $this->assertIsArray( $validity ); foreach ( $error->errors as $code => $messages ) { $this->assertArrayHasKey( $code, $validity ); - $this->assertInternalType( 'array', $validity[ $code ] ); + $this->assertIsArray( $validity[ $code ] ); $this->assertSame( implode( ' ', $messages ), $validity[ $code ]['message'] ); $this->assertArrayHasKey( 'data', $validity[ $code ] ); $this->assertSame( $validity[ $code ]['data'], $error->get_error_data( $code ) ); @@ -2910,7 +2910,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @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" ); } @@ -2927,8 +2927,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { */ function filter_customize_dynamic_setting_class_for_test_dynamic_settings( $setting_class, $setting_id, $setting_args ) { $this->assertSame( 'WP_Customize_Setting', $setting_class ); - $this->assertInternalType( 'string', $setting_id ); - $this->assertInternalType( 'array', $setting_args ); + $this->assertIsString( $setting_id ); + $this->assertIsArray( $setting_args ); return $setting_class; } @@ -3039,7 +3039,7 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { */ function test_nonces() { $nonces = $this->manager->get_nonces(); - $this->assertInternalType( 'array', $nonces ); + $this->assertIsArray( $nonces ); $this->assertArrayHasKey( 'save', $nonces ); $this->assertArrayHasKey( 'preview', $nonces ); @@ -3203,10 +3203,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @return array Components. */ function return_array_containing_widgets( $components, $customize_manager ) { - $this->assertInternalType( 'array', $components ); + $this->assertIsArray( $components ); $this->assertContains( 'widgets', $components ); $this->assertContains( 'nav_menus', $components ); - $this->assertInternalType( 'array', $components ); + $this->assertIsArray( $components ); $this->assertInstanceOf( 'WP_Customize_Manager', $customize_manager ); return array( 'widgets' ); } @@ -3220,10 +3220,10 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase { * @return array Components. */ function return_array_containing_nav_menus( $components, $customize_manager ) { - $this->assertInternalType( 'array', $components ); + $this->assertIsArray( $components ); $this->assertContains( 'widgets', $components ); $this->assertContains( 'nav_menus', $components ); - $this->assertInternalType( 'array', $components ); + $this->assertIsArray( $components ); $this->assertInstanceOf( 'WP_Customize_Manager', $customize_manager ); return array( 'nav_menus' ); } diff --git a/tests/phpunit/tests/customize/nav-menu-item-setting.php b/tests/phpunit/tests/customize/nav-menu-item-setting.php index 2409f32885..68bdd9aba9 100644 --- a/tests/phpunit/tests/customize/nav-menu-item-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-item-setting.php @@ -73,7 +73,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { $this->assertNull( $setting->previous_post_id ); $this->assertNull( $setting->update_status ); $this->assertNull( $setting->update_error ); - $this->assertInternalType( 'array', $setting->default ); + $this->assertIsArray( $setting->default ); $default = array( 'object_id' => 0, @@ -533,7 +533,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { ); foreach ( $valid_urls as $valid_url ) { $url_setting = $setting->sanitize( array( 'url' => $valid_url ) ); - $this->assertInternalType( 'array', $url_setting ); + $this->assertIsArray( $url_setting ); $this->assertSame( $valid_url, $url_setting['url'] ); } diff --git a/tests/phpunit/tests/customize/nav-menu-setting.php b/tests/phpunit/tests/customize/nav-menu-setting.php index 6746b8b1f4..3a9fd76b21 100644 --- a/tests/phpunit/tests/customize/nav-menu-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-setting.php @@ -70,7 +70,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { $this->assertNull( $setting->previous_term_id ); $this->assertNull( $setting->update_status ); $this->assertNull( $setting->update_error ); - $this->assertInternalType( 'array', $setting->default ); + $this->assertIsArray( $setting->default ); foreach ( array( 'name', 'description', 'parent' ) as $key ) { $this->assertArrayHasKey( $key, $setting->default ); } @@ -149,7 +149,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { $setting = new WP_Customize_Nav_Menu_Setting( $this->wp_customize, $setting_id ); $value = $setting->value(); - $this->assertInternalType( 'array', $value ); + $this->assertIsArray( $value ); foreach ( array( 'name', 'description', 'parent' ) as $key ) { $this->assertArrayHasKey( $key, $value ); } @@ -225,7 +225,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { $menus = wp_get_nav_menus(); $menus_ids = wp_list_pluck( $menus, 'term_id' ); $i = array_search( $menu_id, $menus_ids, true ); - $this->assertInternalType( 'int', $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' ); + $this->assertIsInt( $i, 'Update-previewed menu does not appear in wp_get_nav_menus()' ); $filtered_menu = $menus[ $i ]; $this->assertSame( 'Name 2 \\o/', $filtered_menu->name ); } @@ -270,7 +270,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { $menus = wp_get_nav_menus(); $menus_ids = wp_list_pluck( $menus, 'term_id' ); $i = array_search( $menu_id, $menus_ids, true ); - $this->assertInternalType( 'int', $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' ); + $this->assertIsInt( $i, 'Insert-previewed menu was not injected into wp_get_nav_menus()' ); $filtered_menu = $menus[ $i ]; $this->assertSame( 'New Menu Name 1 \\o/', $filtered_menu->name ); } @@ -304,8 +304,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { $this->wp_customize->set_post_value( $setting_id, false ); - $this->assertInternalType( 'array', $setting->value() ); - $this->assertInternalType( 'object', wp_get_nav_menu_object( $menu_id ) ); + $this->assertIsArray( $setting->value() ); + $this->assertIsObject( wp_get_nav_menu_object( $menu_id ) ); $setting->preview(); $this->assertFalse( $setting->value() ); $this->assertFalse( wp_get_nav_menu_object( $menu_id ) ); diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index 0790b9b3cf..908a7ad4f7 100644 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -381,7 +381,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { ) ); $this->assertSame( $count + 1, $this->filter_count_customize_nav_menu_searched_items ); - $this->assertInternalType( 'array', $results ); + $this->assertIsArray( $results ); $this->assertCount( 3, $results ); remove_filter( 'customize_nav_menu_searched_items', array( $this, 'filter_search' ), 10 ); @@ -465,8 +465,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { * @return array Items. */ function filter_search( $items, $args ) { - $this->assertInternalType( 'array', $items ); - $this->assertInternalType( 'array', $args ); + $this->assertIsArray( $items ); + $this->assertIsArray( $args ); $this->assertArrayHasKey( 's', $args ); $this->assertArrayHasKey( 'pagenum', $args ); $this->filter_count_customize_nav_menu_searched_items += 1; @@ -804,13 +804,13 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { do_action( 'customize_register', $this->wp_customize ); $args = apply_filters( 'customize_dynamic_partial_args', false, 'nav_menu_instance[68b329da9893e34099c7d8ad5cb9c940]' ); - $this->assertInternalType( 'array', $args ); + $this->assertIsArray( $args ); $this->assertSame( 'nav_menu_instance', $args['type'] ); $this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] ); $this->assertTrue( $args['container_inclusive'] ); $args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'nav_menu_instance[4099c7d8ad5cb9c94068b329da9893e3]' ); - $this->assertInternalType( 'array', $args ); + $this->assertIsArray( $args ); $this->assertSame( 'nav_menu_instance', $args['type'] ); $this->assertSame( array( $this->wp_customize->nav_menus, 'render_nav_menu_partial' ), $args['render_callback'] ); $this->assertTrue( $args['container_inclusive'] ); diff --git a/tests/phpunit/tests/customize/panel.php b/tests/phpunit/tests/customize/panel.php index 063df5ee09..6a5f30b3e7 100644 --- a/tests/phpunit/tests/customize/panel.php +++ b/tests/phpunit/tests/customize/panel.php @@ -31,7 +31,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { */ function test_construct_default_args() { $panel = new WP_Customize_Panel( $this->manager, 'foo' ); - $this->assertInternalType( 'int', $panel->instance_number ); + $this->assertIsInt( $panel->instance_number ); $this->assertSame( $this->manager, $panel->manager ); $this->assertSame( 'foo', $panel->id ); $this->assertSame( 160, $panel->priority ); @@ -125,7 +125,7 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase { } $this->assertEmpty( $data['content'] ); $this->assertTrue( $data['active'] ); - $this->assertInternalType( 'int', $data['instanceNumber'] ); + $this->assertIsInt( $data['instanceNumber'] ); } /** diff --git a/tests/phpunit/tests/customize/partial.php b/tests/phpunit/tests/customize/partial.php index c7e6126c40..8d2723c1ab 100644 --- a/tests/phpunit/tests/customize/partial.php +++ b/tests/phpunit/tests/customize/partial.php @@ -166,7 +166,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { function filter_customize_partial_render( $rendered, $partial, $container_context ) { $this->assertTrue( false === $rendered || is_string( $rendered ) ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); - $this->assertInternalType( 'array', $container_context ); + $this->assertIsArray( $container_context ); $this->count_filter_customize_partial_render += 1; return $rendered; } @@ -183,7 +183,7 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase { $this->assertSame( sprintf( 'customize_partial_render_%s', $partial->id ), current_filter() ); $this->assertTrue( false === $rendered || is_string( $rendered ) ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); - $this->assertInternalType( 'array', $container_context ); + $this->assertIsArray( $container_context ); $this->count_filter_customize_partial_render_with_id += 1; return $rendered; } diff --git a/tests/phpunit/tests/customize/section.php b/tests/phpunit/tests/customize/section.php index f48ca03b4b..d55649d71e 100644 --- a/tests/phpunit/tests/customize/section.php +++ b/tests/phpunit/tests/customize/section.php @@ -38,7 +38,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { */ function test_construct_default_args() { $section = new WP_Customize_Section( $this->manager, 'foo' ); - $this->assertInternalType( 'int', $section->instance_number ); + $this->assertIsInt( $section->instance_number ); $this->assertSame( $this->manager, $section->manager ); $this->assertSame( 'foo', $section->id ); $this->assertSame( 160, $section->priority ); @@ -139,7 +139,7 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase { } $this->assertEmpty( $data['content'] ); $this->assertTrue( $data['active'] ); - $this->assertInternalType( 'int', $data['instanceNumber'] ); + $this->assertIsInt( $data['instanceNumber'] ); } /** diff --git a/tests/phpunit/tests/customize/selective-refresh-ajax.php b/tests/phpunit/tests/customize/selective-refresh-ajax.php index 2f6e4a0f3b..156af4338b 100644 --- a/tests/phpunit/tests/customize/selective-refresh-ajax.php +++ b/tests/phpunit/tests/customize/selective-refresh-ajax.php @@ -160,7 +160,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { } $output = json_decode( ob_get_clean(), true ); $this->assertTrue( $output['success'] ); - $this->assertInternalType( 'array', $output['data'] ); + $this->assertIsArray( $output['data'] ); $this->assertArrayHasKey( 'contents', $output['data'] ); $this->assertArrayHasKey( 'errors', $output['data'] ); $this->assertArrayHasKey( 'foo', $output['data']['contents'] ); @@ -280,7 +280,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * @return string */ function render_callback_blogname( $partial, $context ) { - $this->assertInternalType( 'array', $context ); + $this->assertIsArray( $context ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); return get_bloginfo( 'name', 'display' ); } @@ -293,7 +293,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * @return string */ function render_callback_blogdescription( $partial, $context ) { - $this->assertInternalType( 'array', $context ); + $this->assertIsArray( $context ); $this->assertInstanceOf( 'WP_Customize_Partial', $partial ); $x = get_bloginfo( 'description', 'display' ); return $x; @@ -374,7 +374,7 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase { * @return array Response. */ function filter_customize_render_partials_response( $response, $component, $partial_placements ) { - $this->assertInternalType( 'array', $response ); + $this->assertIsArray( $response ); $this->assertInstanceOf( 'WP_Customize_Selective_Refresh', $component ); if ( isset( $this->expected_partial_ids ) ) { $this->assertSameSets( $this->expected_partial_ids, array_keys( $partial_placements ) ); diff --git a/tests/phpunit/tests/customize/selective-refresh.php b/tests/phpunit/tests/customize/selective-refresh.php index cd0ce2ebc6..adaac5f4b2 100644 --- a/tests/phpunit/tests/customize/selective-refresh.php +++ b/tests/phpunit/tests/customize/selective-refresh.php @@ -71,7 +71,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * @see WP_Customize_Selective_Refresh::partials() */ function test_partials() { - $this->assertInternalType( 'array', $this->selective_refresh->partials() ); + $this->assertIsArray( $this->selective_refresh->partials() ); } /** @@ -163,9 +163,9 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { $html = ob_get_clean(); $this->assertTrue( (bool) preg_match( '/_customizePartialRefreshExports = ({.+})/s', $html, $matches ) ); $exported_data = json_decode( $matches[1], true ); - $this->assertInternalType( 'array', $exported_data ); + $this->assertIsArray( $exported_data ); $this->assertArrayHasKey( 'partials', $exported_data ); - $this->assertInternalType( 'array', $exported_data['partials'] ); + $this->assertIsArray( $exported_data['partials'] ); $this->assertArrayHasKey( 'blogname', $exported_data['partials'] ); $this->assertArrayNotHasKey( 'top_secret_message', $exported_data['partials'] ); $this->assertSame( '#site-title', $exported_data['partials']['blogname']['selector'] ); @@ -208,7 +208,7 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { */ 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( @@ -230,9 +230,9 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase { * @return string */ function filter_customize_dynamic_partial_class( $partial_class, $partial_id, $partial_args ) { - $this->assertInternalType( 'array', $partial_args ); - $this->assertInternalType( 'string', $partial_id ); - $this->assertInternalType( 'string', $partial_class ); + $this->assertIsArray( $partial_args ); + $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 c382c343f1..46a5897007 100644 --- a/tests/phpunit/tests/customize/setting.php +++ b/tests/phpunit/tests/customize/setting.php @@ -730,7 +730,7 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase { */ 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/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index d157d52261..595021d96b 100644 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -235,7 +235,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $this->do_customize_boot_actions(); $selective_refreshable_widgets = $this->manager->widgets->get_selective_refreshable_widgets(); - $this->assertInternalType( 'array', $selective_refreshable_widgets ); + $this->assertIsArray( $selective_refreshable_widgets ); $this->assertSame( count( $wp_widget_factory->widgets ), count( $selective_refreshable_widgets ) ); $this->assertArrayHasKey( 'text', $selective_refreshable_widgets ); $this->assertTrue( $selective_refreshable_widgets['text'] ); @@ -620,7 +620,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $this->assertArrayHasKey( 'sidebar_id', $params ); $this->assertArrayHasKey( 'width', $params ); $this->assertArrayHasKey( 'height', $params ); - $this->assertInternalType( 'bool', $params['is_wide'] ); + $this->assertIsBool( $params['is_wide'] ); } /** @@ -677,7 +677,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $this->assertArrayNotHasKey( $setting_id, $this->manager->unsanitized_post_values() ); $result = $this->manager->widgets->call_widget_update( $widget_id ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertArrayHasKey( 'instance', $result ); $this->assertArrayHasKey( 'form', $result ); $this->assertSame( $instance, $result['instance'] ); @@ -686,7 +686,7 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { $post_values = $this->manager->unsanitized_post_values(); $this->assertArrayHasKey( $setting_id, $post_values ); $post_value = $post_values[ $setting_id ]; - $this->assertInternalType( 'array', $post_value ); + $this->assertIsArray( $post_value ); $this->assertArrayHasKey( 'title', $post_value ); $this->assertArrayHasKey( 'encoded_serialized_instance', $post_value ); $this->assertArrayHasKey( 'instance_hash_key', $post_value ); @@ -703,13 +703,13 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase { do_action( 'customize_register', $this->manager ); $args = apply_filters( 'customize_dynamic_partial_args', false, 'widget[search-2]' ); - $this->assertInternalType( 'array', $args ); + $this->assertIsArray( $args ); $this->assertSame( 'widget', $args['type'] ); $this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); $this->assertTrue( $args['container_inclusive'] ); $args = apply_filters( 'customize_dynamic_partial_args', array( 'fallback_refresh' => false ), 'widget[search-2]' ); - $this->assertInternalType( 'array', $args ); + $this->assertIsArray( $args ); $this->assertSame( 'widget', $args['type'] ); $this->assertSame( array( $this->manager->widgets, 'render_widget_partial' ), $args['render_callback'] ); $this->assertTrue( $args['container_inclusive'] ); diff --git a/tests/phpunit/tests/date/currentTime.php b/tests/phpunit/tests/date/currentTime.php index dd567701f9..c98292ef0d 100644 --- a/tests/phpunit/tests/date/currentTime.php +++ b/tests/phpunit/tests/date/currentTime.php @@ -99,7 +99,7 @@ class Tests_Date_CurrentTime extends WP_UnitTestCase { $this->assertEqualsWithDelta( $wp_timestamp, current_time( 'U' ), 2, 'The dates should be equal' ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested - $this->assertInternalType( 'int', current_time( 'timestamp' ) ); + $this->assertIsInt( current_time( 'timestamp' ) ); } /** diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index 29259d924f..0ebc357666 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -560,7 +560,7 @@ class Tests_DB extends WP_UnitTestCase { $this->assertNotEmpty( $wpdb->insert_id ); $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->users WHERE ID = %d", $wpdb->insert_id ) ); - $this->assertInternalType( 'object', $row ); + $this->assertIsObject( $row ); $this->assertSame( 'Walter Sobchak', $row->display_name ); } @@ -1682,7 +1682,7 @@ class Tests_DB extends WP_UnitTestCase { if ( $expect_bail ) { $this->assertFalse( $data ); } else { - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); list( $parsed_host, $parsed_port, $parsed_socket, $parsed_is_ipv6 ) = $data; diff --git a/tests/phpunit/tests/formatting/SanitizePost.php b/tests/phpunit/tests/formatting/SanitizePost.php index 3034ebbd02..7a4d289262 100644 --- a/tests/phpunit/tests/formatting/SanitizePost.php +++ b/tests/phpunit/tests/formatting/SanitizePost.php @@ -19,7 +19,14 @@ class Tests_Formatting_SanitizePost extends WP_UnitTestCase { ); foreach ( $int_fields as $field => $type ) { - $this->assertInternalType( $type, $post->$field, "field $field" ); + switch ( $type ) { + case 'integer': + $this->assertIsInt( $post->$field, "field $field" ); + break; + case 'string': + $this->assertIsString( $post->$field, "field $field" ); + break; + } } } } diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index d3c7abbef0..02bc5e7e9a 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -80,8 +80,8 @@ class Tests_Functions extends WP_UnitTestCase { */ 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'] ); } /** @@ -581,17 +581,17 @@ class Tests_Functions extends WP_UnitTestCase { function test_get_allowed_mime_types() { $mimes = get_allowed_mime_types(); - $this->assertInternalType( 'array', $mimes ); + $this->assertIsArray( $mimes ); $this->assertNotEmpty( $mimes ); add_filter( 'upload_mimes', '__return_empty_array' ); $mimes = get_allowed_mime_types(); - $this->assertInternalType( 'array', $mimes ); + $this->assertIsArray( $mimes ); $this->assertEmpty( $mimes ); remove_filter( 'upload_mimes', '__return_empty_array' ); $mimes = get_allowed_mime_types(); - $this->assertInternalType( 'array', $mimes ); + $this->assertIsArray( $mimes ); $this->assertNotEmpty( $mimes ); } @@ -601,28 +601,28 @@ class Tests_Functions extends WP_UnitTestCase { function test_wp_get_mime_types() { $mimes = wp_get_mime_types(); - $this->assertInternalType( 'array', $mimes ); + $this->assertIsArray( $mimes ); $this->assertNotEmpty( $mimes ); add_filter( 'mime_types', '__return_empty_array' ); $mimes = wp_get_mime_types(); - $this->assertInternalType( 'array', $mimes ); + $this->assertIsArray( $mimes ); $this->assertEmpty( $mimes ); remove_filter( 'mime_types', '__return_empty_array' ); $mimes = wp_get_mime_types(); - $this->assertInternalType( 'array', $mimes ); + $this->assertIsArray( $mimes ); $this->assertNotEmpty( $mimes ); // 'upload_mimes' should not affect wp_get_mime_types(). add_filter( 'upload_mimes', '__return_empty_array' ); $mimes = wp_get_mime_types(); - $this->assertInternalType( 'array', $mimes ); + $this->assertIsArray( $mimes ); $this->assertNotEmpty( $mimes ); remove_filter( 'upload_mimes', '__return_empty_array' ); $mimes2 = wp_get_mime_types(); - $this->assertInternalType( 'array', $mimes2 ); + $this->assertIsArray( $mimes2 ); $this->assertNotEmpty( $mimes2 ); $this->assertSame( $mimes2, $mimes ); } @@ -910,7 +910,7 @@ class Tests_Functions extends WP_UnitTestCase { $urls = wp_extract_urls( $blob ); $this->assertNotEmpty( $urls ); - $this->assertInternalType( 'array', $urls ); + $this->assertIsArray( $urls ); $this->assertCount( count( $original_urls ), $urls ); $this->assertSame( $original_urls, $urls ); @@ -931,7 +931,7 @@ class Tests_Functions extends WP_UnitTestCase { $urls = wp_extract_urls( $blob ); $this->assertNotEmpty( $urls ); - $this->assertInternalType( 'array', $urls ); + $this->assertIsArray( $urls ); $this->assertCount( 8, $urls ); $this->assertSame( array_slice( $original_urls, 0, 8 ), $urls ); @@ -945,7 +945,7 @@ class Tests_Functions extends WP_UnitTestCase { $urls = wp_extract_urls( $blob ); $this->assertNotEmpty( $urls ); - $this->assertInternalType( 'array', $urls ); + $this->assertIsArray( $urls ); $this->assertCount( 8, $urls ); $this->assertSame( array_slice( $original_urls, 0, 8 ), $urls ); } @@ -1066,7 +1066,7 @@ class Tests_Functions extends WP_UnitTestCase { public function test_wp_get_ext_types() { $extensions = wp_get_ext_types(); - $this->assertInternalType( 'array', $extensions ); + $this->assertIsArray( $extensions ); $this->assertNotEmpty( $extensions ); add_filter( 'ext2type', '__return_empty_array' ); @@ -1075,7 +1075,7 @@ class Tests_Functions extends WP_UnitTestCase { remove_filter( 'ext2type', '__return_empty_array' ); $extensions = wp_get_ext_types(); - $this->assertInternalType( 'array', $extensions ); + $this->assertIsArray( $extensions ); $this->assertNotEmpty( $extensions ); } @@ -1197,7 +1197,7 @@ class Tests_Functions extends WP_UnitTestCase { $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/listFiles.php b/tests/phpunit/tests/functions/listFiles.php index 484ecd6230..a70a058940 100644 --- a/tests/phpunit/tests/functions/listFiles.php +++ b/tests/phpunit/tests/functions/listFiles.php @@ -10,7 +10,7 @@ class Tests_Functions_ListFiles extends WP_UnitTestCase { public function test_list_files_returns_a_list_of_files() { $admin_files = list_files( ABSPATH . 'wp-admin/' ); - $this->assertInternalType( 'array', $admin_files ); + $this->assertIsArray( $admin_files ); $this->assertNotEmpty( $admin_files ); $this->assertContains( ABSPATH . 'wp-admin/index.php', $admin_files ); } diff --git a/tests/phpunit/tests/functions/wpGetMimeTypes.php b/tests/phpunit/tests/functions/wpGetMimeTypes.php index 46d2fdfc06..2bef07644f 100644 --- a/tests/phpunit/tests/functions/wpGetMimeTypes.php +++ b/tests/phpunit/tests/functions/wpGetMimeTypes.php @@ -14,7 +14,7 @@ class Tests_Functions_wpGetMimeTypes extends WP_UnitTestCase { public function test_all_mime_match() { $mime_types_start = wp_get_mime_types(); - $this->assertInternalType( 'array', $mime_types_start ); + $this->assertIsArray( $mime_types_start ); $this->assertNotEmpty( $mime_types_start ); add_filter( 'mime_types', '__return_empty_array' ); @@ -23,7 +23,7 @@ class Tests_Functions_wpGetMimeTypes extends WP_UnitTestCase { remove_filter( 'mime_types', '__return_empty_array' ); $mime_types = wp_get_mime_types(); - $this->assertInternalType( 'array', $mime_types ); + $this->assertIsArray( $mime_types ); $this->assertNotEmpty( $mime_types ); // Did it revert to the original after filter remove? $this->assertSame( $mime_types_start, $mime_types ); diff --git a/tests/phpunit/tests/functions/wpRemoteFopen.php b/tests/phpunit/tests/functions/wpRemoteFopen.php index 1a4fa19619..e29c9d3181 100644 --- a/tests/phpunit/tests/functions/wpRemoteFopen.php +++ b/tests/phpunit/tests/functions/wpRemoteFopen.php @@ -29,7 +29,7 @@ class Tests_Functions_wpRemoteFopen extends WP_UnitTestCase { $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->assertSame( 40148, strlen( $response ) ); } } diff --git a/tests/phpunit/tests/general/template.php b/tests/phpunit/tests/general/template.php index d412917466..49545adb90 100644 --- a/tests/phpunit/tests/general/template.php +++ b/tests/phpunit/tests/general/template.php @@ -304,7 +304,7 @@ class Tests_General_Template extends WP_UnitTestCase { $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/general/wpGetArchives.php b/tests/phpunit/tests/general/wpGetArchives.php index 0f17fd1330..3c7117af93 100644 --- a/tests/phpunit/tests/general/wpGetArchives.php +++ b/tests/phpunit/tests/general/wpGetArchives.php @@ -31,7 +31,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $time1 = wp_cache_get( 'last_changed', 'posts' ); $this->assertNotEmpty( $time1 ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -45,7 +45,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); @@ -57,7 +57,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'order' => 'ASC', ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -71,7 +71,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'order' => 'ASC', ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); @@ -84,7 +84,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -97,7 +97,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); @@ -108,7 +108,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -121,7 +121,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); @@ -132,7 +132,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -145,7 +145,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); @@ -156,7 +156,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries + 1, $wpdb->num_queries ); @@ -169,7 +169,7 @@ class Tests_General_wpGetArchives extends WP_UnitTestCase { 'echo' => false, ) ); - $this->assertInternalType( 'string', $result ); + $this->assertIsString( $result ); $this->assertSame( $time1, wp_cache_get( 'last_changed', 'posts' ) ); $this->assertSame( $num_queries, $wpdb->num_queries ); } diff --git a/tests/phpunit/tests/http/base.php b/tests/phpunit/tests/http/base.php index d93c3fb9fd..2dd254a7fa 100644 --- a/tests/phpunit/tests/http/base.php +++ b/tests/phpunit/tests/http/base.php @@ -452,7 +452,7 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { $res = wp_remote_head( $url, array( 'timeout' => 30 ) ); $this->skipTestOnTimeout( $res ); - $this->assertInternalType( 'array', wp_remote_retrieve_header( $res, 'location' ) ); + $this->assertIsArray( wp_remote_retrieve_header( $res, 'location' ) ); $this->assertCount( 2, wp_remote_retrieve_header( $res, 'location' ) ); $res = wp_remote_get( $url, array( 'timeout' => 30 ) ); diff --git a/tests/phpunit/tests/http/functions.php b/tests/phpunit/tests/http/functions.php index 236177266f..05500cc407 100644 --- a/tests/phpunit/tests/http/functions.php +++ b/tests/phpunit/tests/http/functions.php @@ -19,7 +19,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $headers = wp_remote_retrieve_headers( $response ); - $this->assertInternalType( 'array', $response ); + $this->assertIsArray( $response ); $this->assertSame( 'image/jpeg', $headers['content-type'] ); $this->assertSame( '40148', $headers['content-length'] ); @@ -63,7 +63,7 @@ class Tests_HTTP_Functions extends WP_UnitTestCase { $headers = wp_remote_retrieve_headers( $response ); - $this->assertInternalType( 'array', $response ); + $this->assertIsArray( $response ); // Should return the same headers as a HEAD request. $this->assertSame( 'image/jpeg', $headers['content-type'] ); diff --git a/tests/phpunit/tests/image/functions.php b/tests/phpunit/tests/image/functions.php index 30459c5e77..6b1e371f1e 100644 --- a/tests/phpunit/tests/image/functions.php +++ b/tests/phpunit/tests/image/functions.php @@ -337,7 +337,7 @@ class Tests_Image_Functions extends WP_UnitTestCase { // First, test with deprecated wp_load_image function. $editor1 = wp_load_image( DIR_TESTDATA ); - $this->assertInternalType( 'string', $editor1 ); + $this->assertIsString( $editor1 ); $editor2 = wp_get_image_editor( DIR_TESTDATA ); $this->assertInstanceOf( 'WP_Error', $editor2 ); diff --git a/tests/phpunit/tests/image/header.php b/tests/phpunit/tests/image/header.php index 897c68e5fa..99848bba0a 100644 --- a/tests/phpunit/tests/image/header.php +++ b/tests/phpunit/tests/image/header.php @@ -147,7 +147,7 @@ class Tests_Image_Header extends WP_UnitTestCase { $cropped_id = $this->custom_image_header->insert_attachment( $object, $cropped ); - $this->assertInternalType( 'int', $cropped_id ); + $this->assertIsInt( $cropped_id ); $this->assertGreaterThan( 0, $cropped_id ); } diff --git a/tests/phpunit/tests/image/intermediateSize.php b/tests/phpunit/tests/image/intermediateSize.php index 86e2c87323..b44334c70a 100644 --- a/tests/phpunit/tests/image/intermediateSize.php +++ b/tests/phpunit/tests/image/intermediateSize.php @@ -34,7 +34,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { function test_make_intermediate_size_width() { $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false ); - $this->assertInternalType( 'array', $image ); + $this->assertIsArray( $image ); } /** @@ -43,7 +43,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { function test_make_intermediate_size_height() { $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false ); - $this->assertInternalType( 'array', $image ); + $this->assertIsArray( $image ); } /** @@ -54,7 +54,7 @@ class Tests_Image_Intermediate_Size extends WP_UnitTestCase { unlink( DIR_TESTDATA . '/images/a2-small-100x75.jpg' ); - $this->assertInternalType( 'array', $image ); + $this->assertIsArray( $image ); $this->assertSame( 100, $image['width'] ); $this->assertSame( 75, $image['height'] ); $this->assertSame( 'image/jpeg', $image['mime-type'] ); diff --git a/tests/phpunit/tests/image/siteIcon.php b/tests/phpunit/tests/image/siteIcon.php index 595a1a5f21..8e65a7bdc0 100644 --- a/tests/phpunit/tests/image/siteIcon.php +++ b/tests/phpunit/tests/image/siteIcon.php @@ -120,7 +120,7 @@ class Tests_WP_Site_Icon extends WP_UnitTestCase { $object = $this->wp_site_icon->create_attachment_object( $cropped, $attachment_id ); $cropped_id = $this->wp_site_icon->insert_attachment( $object, $cropped ); - $this->assertInternalType( 'int', $cropped_id ); + $this->assertIsInt( $cropped_id ); $this->assertGreaterThan( 0, $cropped_id ); } diff --git a/tests/phpunit/tests/includes/factory.php b/tests/phpunit/tests/includes/factory.php index 8fd351e772..47d0968f2b 100644 --- a/tests/phpunit/tests/includes/factory.php +++ b/tests/phpunit/tests/includes/factory.php @@ -35,7 +35,7 @@ class TestFactoryFor extends WP_UnitTestCase { public function test_term_factory_create_and_get_should_return_term_object() { register_taxonomy( 'wptests_tax', 'post' ); $term = self::factory()->term->create_and_get( array( 'taxonomy' => 'wptests_tax' ) ); - $this->assertInternalType( 'object', $term ); + $this->assertIsObject( $term ); $this->assertNotEmpty( $term->term_id ); } } diff --git a/tests/phpunit/tests/l10n.php b/tests/phpunit/tests/l10n.php index d62ca1f532..b4bbb07725 100644 --- a/tests/phpunit/tests/l10n.php +++ b/tests/phpunit/tests/l10n.php @@ -56,7 +56,7 @@ class Tests_L10n extends WP_UnitTestCase { */ function test_get_available_languages() { $array = get_available_languages(); - $this->assertInternalType( 'array', $array ); + $this->assertIsArray( $array ); $array = get_available_languages( '.' ); $this->assertEmpty( $array ); @@ -70,7 +70,7 @@ class Tests_L10n extends WP_UnitTestCase { */ function test_wp_get_installed_translations_for_core() { $installed_translations = wp_get_installed_translations( 'core' ); - $this->assertInternalType( 'array', $installed_translations ); + $this->assertIsArray( $installed_translations ); $textdomains_expected = array( 'admin', 'admin-network', 'continents-cities', 'default' ); $this->assertSameSets( $textdomains_expected, array_keys( $installed_translations ) ); diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index 342e035536..6ff6ac3822 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -381,7 +381,7 @@ https://w.org', $post = get_post( $id ); $prepped = wp_prepare_attachment_for_js( $post ); - $this->assertInternalType( 'array', $prepped ); + $this->assertIsArray( $prepped ); $this->assertSame( 0, $prepped['uploadedTo'] ); $this->assertSame( '', $prepped['mime'] ); $this->assertSame( '', $prepped['type'] ); @@ -1164,7 +1164,7 @@ VIDEO; */ function test_attachment_url_to_postid_with_empty_url() { $post_id = attachment_url_to_postid( '' ); - $this->assertInternalType( 'int', $post_id ); + $this->assertIsInt( $post_id ); $this->assertSame( 0, $post_id ); } diff --git a/tests/phpunit/tests/media/getAttachmentTaxonomies.php b/tests/phpunit/tests/media/getAttachmentTaxonomies.php index f777d5d060..bf1549ff2b 100644 --- a/tests/phpunit/tests/media/getAttachmentTaxonomies.php +++ b/tests/phpunit/tests/media/getAttachmentTaxonomies.php @@ -119,7 +119,7 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase { $found = get_attachment_taxonomies( $attachment, 'objects' ); $this->assertSame( array( 'wptests_tax2' ), array_keys( $found ) ); - $this->assertInternalType( 'object', $found['wptests_tax2'] ); + $this->assertIsObject( $found['wptests_tax2'] ); $this->assertSame( 'wptests_tax2', $found['wptests_tax2']->name ); } @@ -143,7 +143,7 @@ class Tests_Media_GetAttachmentTaxonomies extends WP_UnitTestCase { $found = get_attachment_taxonomies( $attachment, 'objects' ); $this->assertSame( array( 'wptests_tax2' ), array_keys( $found ) ); - $this->assertInternalType( 'object', $found['wptests_tax2'] ); + $this->assertIsObject( $found['wptests_tax2'] ); $this->assertSame( 'wptests_tax2', $found['wptests_tax2']->name ); } } diff --git a/tests/phpunit/tests/meta.php b/tests/phpunit/tests/meta.php index a99674c973..9ea6b5817b 100644 --- a/tests/phpunit/tests/meta.php +++ b/tests/phpunit/tests/meta.php @@ -207,11 +207,11 @@ class Tests_Meta extends WP_UnitTestCase { $this->assertFalse( metadata_exists( 'user', $this->author->ID, $key ) ); $this->assertFalse( delete_metadata( 'user', $this->author->ID, $key ) ); $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); - $this->assertInternalType( 'int', add_metadata( 'user', $this->author->ID, $key, $value ) ); + $this->assertIsInt( add_metadata( 'user', $this->author->ID, $key, $value ) ); $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); - $this->assertInternalType( 'int', update_metadata( 'user', $this->author->ID, $key, $value ) ); + $this->assertIsInt( update_metadata( 'user', $this->author->ID, $key, $value ) ); $this->assertSame( $expected, get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertTrue( update_metadata( 'user', $this->author->ID, $key, 'blah' ) ); $this->assertSame( 'blah', get_metadata( 'user', $this->author->ID, $key, true ) ); @@ -220,11 +220,11 @@ class Tests_Meta extends WP_UnitTestCase { $this->assertFalse( metadata_exists( 'user', $this->author->ID, $key ) ); // Test overslashing. - $this->assertInternalType( 'int', add_metadata( 'user', $this->author->ID, $key, $value2 ) ); + $this->assertIsInt( add_metadata( 'user', $this->author->ID, $key, $value2 ) ); $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); $this->assertTrue( delete_metadata( 'user', $this->author->ID, $key ) ); $this->assertSame( '', get_metadata( 'user', $this->author->ID, $key, true ) ); - $this->assertInternalType( 'int', update_metadata( 'user', $this->author->ID, $key, $value2 ) ); + $this->assertIsInt( update_metadata( 'user', $this->author->ID, $key, $value2 ) ); $this->assertSame( $expected2, get_metadata( 'user', $this->author->ID, $key, true ) ); } diff --git a/tests/phpunit/tests/multisite/cleanDirsizeCache.php b/tests/phpunit/tests/multisite/cleanDirsizeCache.php index bcc95e6359..2ca6b1fca1 100644 --- a/tests/phpunit/tests/multisite/cleanDirsizeCache.php +++ b/tests/phpunit/tests/multisite/cleanDirsizeCache.php @@ -206,7 +206,7 @@ if ( is_multisite() ) : // `dirsize_cache` should now be filled after upload and recurse_dirsize() call. $cache_path = untrailingslashit( $upload_dir['path'] ); - $this->assertInternalType( 'array', get_transient( 'dirsize_cache' ) ); + $this->assertIsArray( get_transient( 'dirsize_cache' ) ); $this->assertSame( $size, get_transient( 'dirsize_cache' )[ $cache_path ] ); // Cleanup. diff --git a/tests/phpunit/tests/multisite/network.php b/tests/phpunit/tests/multisite/network.php index 3742baf959..f8ad85afe8 100644 --- a/tests/phpunit/tests/multisite/network.php +++ b/tests/phpunit/tests/multisite/network.php @@ -352,7 +352,7 @@ if ( is_multisite() ) : // We can't use wp_schedule_update_network_counts() because WP_INSTALLING is set. wp_schedule_event( time(), 'twicedaily', 'update_network_counts' ); - $this->assertInternalType( 'int', wp_next_scheduled( 'update_network_counts' ) ); + $this->assertIsInt( wp_next_scheduled( 'update_network_counts' ) ); } /** @@ -365,7 +365,7 @@ if ( is_multisite() ) : $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); $blog_id = self::factory()->blog->create( array( 'user_id' => $user_id ) ); - $this->assertInternalType( 'int', $blog_id ); + $this->assertIsInt( $blog_id ); // Set the dashboard blog to another one. update_site_option( 'dashboard_blog', $blog_id ); diff --git a/tests/phpunit/tests/multisite/site.php b/tests/phpunit/tests/multisite/site.php index cdff67e927..5e87c61c2c 100644 --- a/tests/phpunit/tests/multisite/site.php +++ b/tests/phpunit/tests/multisite/site.php @@ -94,7 +94,7 @@ if ( is_multisite() ) : $this->assertSame( array(), $_wp_switched_stack ); $this->assertFalse( ms_is_switched() ); $current_blog_id = get_current_blog_id(); - $this->assertInternalType( 'integer', $current_blog_id ); + $this->assertIsInt( $current_blog_id ); wp_cache_set( 'switch-test', $current_blog_id, 'switch-test' ); $this->assertSame( $current_blog_id, wp_cache_get( 'switch-test', 'switch-test' ) ); @@ -141,7 +141,7 @@ if ( is_multisite() ) : $blog_id = self::factory()->blog->create(); - $this->assertInternalType( 'int', $blog_id ); + $this->assertIsInt( $blog_id ); $prefix = $wpdb->get_blog_prefix( $blog_id ); // $get_all = false, only retrieve details from the blogs table. @@ -1328,7 +1328,7 @@ if ( is_multisite() ) : remove_action( 'wp_initialize_site', 'wp_initialize_site', 10 ); $site_id = wp_insert_site( $site_data ); - $this->assertInternalType( 'integer', $site_id ); + $this->assertIsInt( $site_id ); $site = get_site( $site_id ); foreach ( $expected_data as $key => $value ) { @@ -1434,7 +1434,7 @@ if ( is_multisite() ) : remove_action( 'clean_site_cache', array( $this, 'action_database_insert_on_clean_site_cache' ) ); - $this->assertInternalType( 'integer', $site_id ); + $this->assertIsInt( $site_id ); } @@ -1819,7 +1819,7 @@ if ( is_multisite() ) : 'network_id' => 1, ) ); - $this->assertInternalType( 'integer', $site_id ); + $this->assertIsInt( $site_id ); $site = get_site( $site_id ); $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' ); @@ -1827,7 +1827,7 @@ if ( is_multisite() ) : $second_date = current_time( 'mysql', true ); $site_id = wp_update_site( $site_id, array() ); - $this->assertInternalType( 'integer', $site_id ); + $this->assertIsInt( $site_id ); $site = get_site( $site_id ); $this->assertEqualsWithDelta( strtotime( $first_date ), strtotime( $site->registered ), 2, 'The dates should be equal' ); diff --git a/tests/phpunit/tests/multisite/siteMeta.php b/tests/phpunit/tests/multisite/siteMeta.php index ed7ccfdec2..72d86f6a47 100644 --- a/tests/phpunit/tests/multisite/siteMeta.php +++ b/tests/phpunit/tests/multisite/siteMeta.php @@ -157,7 +157,7 @@ if ( is_multisite() ) : } $actual = update_site_meta( self::$site_id, 'foo', 'bar' ); - $this->assertInternalType( 'int', $actual ); + $this->assertIsInt( $actual ); $this->assertNotEmpty( $actual ); $meta = get_site_meta( self::$site_id, 'foo', true ); diff --git a/tests/phpunit/tests/oembed/controller.php b/tests/phpunit/tests/oembed/controller.php index de4548a63a..8cc9f2b884 100644 --- a/tests/phpunit/tests/oembed/controller.php +++ b/tests/phpunit/tests/oembed/controller.php @@ -169,8 +169,8 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { if ( ! is_string( $data ) && false !== $data ) { $this->fail( 'Unexpected type for $data.' ); } - $this->assertInternalType( 'string', $url ); - $this->assertInternalType( 'array', $args ); + $this->assertIsString( $url ); + $this->assertIsArray( $args ); $this->oembed_result_filter_count++; return $data; } @@ -299,7 +299,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertNotEmpty( $data ); } @@ -323,7 +323,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertNotEmpty( $data ); $this->assertArrayHasKey( 'version', $data ); @@ -366,7 +366,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertNotEmpty( $data ); $this->assertArrayHasKey( 'version', $data ); @@ -411,7 +411,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertNotEmpty( $data ); $this->assertArrayHasKey( 'version', $data ); @@ -454,7 +454,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertNotEmpty( $data ); restore_current_blog(); @@ -603,7 +603,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $data = $response->get_data(); $this->assertNotEmpty( $data ); - $this->assertInternalType( 'object', $data ); + $this->assertIsObject( $data ); $this->assertSame( 'YouTube', $data->provider_name ); $this->assertSame( 'https://i.ytimg.com/vi/' . self::YOUTUBE_VIDEO_ID . '/hqdefault.jpg', $data->thumbnail_url ); $this->assertEquals( $data->width, $request['maxwidth'] ); @@ -630,9 +630,9 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $data = $response->get_data(); $this->assertNotEmpty( $data ); - $this->assertInternalType( 'object', $data ); - $this->assertInternalType( 'string', $data->html ); - $this->assertInternalType( 'array', $data->scripts ); + $this->assertIsObject( $data ); + $this->assertIsString( $data->html ); + $this->assertIsArray( $data->scripts ); } public function test_proxy_with_invalid_oembed_provider_no_discovery() { @@ -743,7 +743,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $response = rest_get_server()->dispatch( $request ); $data = $response->get_data(); - $this->assertInternalType( 'object', $data ); + $this->assertIsObject( $data ); $data = (array) $data; @@ -786,7 +786,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $data = $response->get_data(); $this->assertSame( 1, $this->oembed_result_filter_count ); - $this->assertInternalType( 'object', $data ); + $this->assertIsObject( $data ); $this->assertSame( 'Untrusted', $data->provider_name ); $this->assertSame( self::UNTRUSTED_PROVIDER_URL, $data->provider_url ); $this->assertSame( 'rich', $data->type ); @@ -809,7 +809,7 @@ class Test_oEmbed_Controller extends WP_UnitTestCase { $data = $response->get_data(); $this->assertSame( 1, $this->oembed_result_filter_count ); - $this->assertInternalType( 'object', $data ); + $this->assertIsObject( $data ); $this->assertStringStartsWith( 'Unfiltered', $data->html ); } diff --git a/tests/phpunit/tests/option/multisite.php b/tests/phpunit/tests/option/multisite.php index f5e0174ca5..6f4c7f5b0a 100644 --- a/tests/phpunit/tests/option/multisite.php +++ b/tests/phpunit/tests/option/multisite.php @@ -99,7 +99,7 @@ if ( is_multisite() ) : function test_with_another_site() { $user_id = self::factory()->user->create(); - $this->assertInternalType( 'integer', $user_id ); + $this->assertIsInt( $user_id ); $blog_id = self::factory()->blog->create( array( @@ -107,7 +107,7 @@ if ( is_multisite() ) : 'public' => 1, ) ); - $this->assertInternalType( 'integer', $blog_id ); + $this->assertIsInt( $blog_id ); $key = __FUNCTION__ . '_key1'; $key2 = __FUNCTION__ . '_key2'; diff --git a/tests/phpunit/tests/post.php b/tests/phpunit/tests/post.php index 44b8645442..154997c1bf 100644 --- a/tests/phpunit/tests/post.php +++ b/tests/phpunit/tests/post.php @@ -97,12 +97,12 @@ class Tests_Post extends WP_UnitTestCase { update_object_term_cache( $id, $post_type ); $tcache = wp_cache_get( $id, 'post_tag_relationships' ); - $this->assertInternalType( 'array', $tcache ); + $this->assertIsArray( $tcache ); $this->assertSame( 2, count( $tcache ) ); $tcache = wp_cache_get( $id, 'ctax_relationships' ); if ( 'cpt' === $post_type ) { - $this->assertInternalType( 'array', $tcache ); + $this->assertIsArray( $tcache ); $this->assertSame( 2, count( $tcache ) ); } else { $this->assertFalse( $tcache ); diff --git a/tests/phpunit/tests/post/formats.php b/tests/phpunit/tests/post/formats.php index 5fcd7dc1ff..5d462bf776 100644 --- a/tests/phpunit/tests/post/formats.php +++ b/tests/phpunit/tests/post/formats.php @@ -12,7 +12,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 1, count( $result ) ); $format = get_post_format( $post_id ); @@ -20,12 +20,12 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 0, count( $result ) ); $result = set_post_format( $post_id, '' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 0, count( $result ) ); } @@ -40,7 +40,7 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 1, count( $result ) ); // The format can be set but not retrieved until it is registered. $format = get_post_format( $post_id ); @@ -53,12 +53,12 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 0, count( $result ) ); $result = set_post_format( $post_id, '' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 0, count( $result ) ); remove_post_type_support( 'page', 'post-formats' ); @@ -72,13 +72,13 @@ class Tests_Post_Formats extends WP_UnitTestCase { $result = set_post_format( $post_id, 'aside' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 1, count( $result ) ); $this->assertTrue( has_post_format( 'aside', $post_id ) ); $result = set_post_format( $post_id, 'standard' ); $this->assertNotWPError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 0, count( $result ) ); // Standard is a special case. It shows as false when set. $this->assertFalse( has_post_format( 'standard', $post_id ) ); diff --git a/tests/phpunit/tests/post/getPageByPath.php b/tests/phpunit/tests/post/getPageByPath.php index f7912b87be..13e6a3cfe2 100644 --- a/tests/phpunit/tests/post/getPageByPath.php +++ b/tests/phpunit/tests/post/getPageByPath.php @@ -306,15 +306,15 @@ class Tests_Post_GetPageByPath extends WP_UnitTestCase { $this->assertSame( $page, $found->ID ); $object = get_page_by_path( 'foo', OBJECT ); - $this->assertInternalType( 'object', $object ); + $this->assertIsObject( $object ); $this->assertSame( $page, $object->ID ); $array_n = get_page_by_path( 'foo', ARRAY_N ); - $this->assertInternalType( 'array', $array_n ); + $this->assertIsArray( $array_n ); $this->assertSame( $page, $array_n[0] ); $array_a = get_page_by_path( 'foo', ARRAY_A ); - $this->assertInternalType( 'array', $array_a ); + $this->assertIsArray( $array_a ); $this->assertSame( $page, $array_a['ID'] ); } } diff --git a/tests/phpunit/tests/post/getPostTypeLabels.php b/tests/phpunit/tests/post/getPostTypeLabels.php index 0d66ba1f78..9761e419b0 100644 --- a/tests/phpunit/tests/post/getPostTypeLabels.php +++ b/tests/phpunit/tests/post/getPostTypeLabels.php @@ -5,8 +5,7 @@ */ class Tests_Post_GetPostTypeLabels extends WP_UnitTestCase { public function test_returns_an_object() { - $this->assertInternalType( - 'object', + $this->assertIsObject( get_post_type_labels( (object) array( 'name' => 'foo', diff --git a/tests/phpunit/tests/post/meta.php b/tests/phpunit/tests/post/meta.php index 5b338325c0..d8ff74bc62 100644 --- a/tests/phpunit/tests/post/meta.php +++ b/tests/phpunit/tests/post/meta.php @@ -46,7 +46,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_unique_postmeta() { // Add a unique post meta item. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique', 'value', true ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'unique', 'value', true ) ); // Check unique is enforced. $this->assertFalse( add_post_meta( self::$post_id, 'unique', 'another value', true ) ); @@ -69,8 +69,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_nonunique_postmeta() { // Add two non-unique post meta items. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'value' ) ); - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'another value' ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'nonunique', 'value' ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'nonunique', 'another value' ) ); // Check they exist. $this->assertSame( 'value', get_post_meta( self::$post_id, 'nonunique', true ) ); @@ -87,7 +87,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { $this->assertSame( array( 'another value' ), get_post_meta( self::$post_id, 'nonunique', false ) ); // Add a third one. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique', 'someother value' ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'nonunique', 'someother value' ) ); // Check they exist. $expected = array( @@ -106,11 +106,11 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_update_post_meta() { // Add a unique post meta item. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique_update', 'value', true ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'unique_update', 'value', true ) ); // Add two non-unique post meta items. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique_update', 'value' ) ); - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'nonunique_update', 'another value' ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'nonunique_update', 'value' ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'nonunique_update', 'another value' ) ); // Check they exist. $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_update', true ) ); @@ -133,8 +133,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_delete_post_meta() { // Add two unique post meta items. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique_delete', 'value', true ) ); - $this->assertInternalType( 'integer', add_post_meta( self::$post_id_2, 'unique_delete', 'value', true ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'unique_delete', 'value', true ) ); + $this->assertIsInt( add_post_meta( self::$post_id_2, 'unique_delete', 'value', true ) ); // Check they exist. $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_delete', true ) ); @@ -150,8 +150,8 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_delete_post_meta_by_key() { // Add two unique post meta items. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'unique_delete_by_key', 'value', true ) ); - $this->assertInternalType( 'integer', add_post_meta( self::$post_id_2, 'unique_delete_by_key', 'value', true ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'unique_delete_by_key', 'value', true ) ); + $this->assertIsInt( add_post_meta( self::$post_id_2, 'unique_delete_by_key', 'value', true ) ); // Check they exist. $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_delete_by_key', true ) ); @@ -167,7 +167,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_get_post_meta_by_id() { $mid = add_post_meta( self::$post_id, 'get_post_meta_by_key', 'get_post_meta_by_key_value', true ); - $this->assertInternalType( 'integer', $mid ); + $this->assertIsInt( $mid ); $mobj = new stdClass; $mobj->meta_id = $mid; @@ -178,7 +178,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { delete_metadata_by_mid( 'post', $mid ); $mid = add_post_meta( self::$post_id, 'get_post_meta_by_key', array( 'foo', 'bar' ), true ); - $this->assertInternalType( 'integer', $mid ); + $this->assertIsInt( $mid ); $mobj->meta_id = $mid; $mobj->meta_value = array( 'foo', 'bar' ); $this->assertEquals( $mobj, get_post_meta_by_id( $mid ) ); @@ -187,7 +187,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_delete_meta() { $mid = add_post_meta( self::$post_id, 'delete_meta', 'delete_meta_value', true ); - $this->assertInternalType( 'integer', $mid ); + $this->assertIsInt( $mid ); $this->assertTrue( delete_meta( $mid ) ); $this->assertFalse( get_metadata_by_mid( 'post', $mid ) ); @@ -197,11 +197,14 @@ class Tests_Post_Meta extends WP_UnitTestCase { function test_update_meta() { // Add a unique post meta item. - $this->assertInternalType( 'integer', $mid1 = add_post_meta( self::$post_id, 'unique_update', 'value', true ) ); + $mid1 = add_post_meta( self::$post_id, 'unique_update', 'value', true ); + $this->assertIsInt( $mid1 ); // Add two non-unique post meta items. - $this->assertInternalType( 'integer', $mid2 = add_post_meta( self::$post_id, 'nonunique_update', 'value' ) ); - $this->assertInternalType( 'integer', $mid3 = add_post_meta( self::$post_id, 'nonunique_update', 'another value' ) ); + $mid2 = add_post_meta( self::$post_id, 'nonunique_update', 'value' ); + $this->assertIsInt( $mid2 ); + $mid3 = add_post_meta( self::$post_id, 'nonunique_update', 'another value' ); + $this->assertIsInt( $mid3 ); // Check they exist. $this->assertSame( 'value', get_post_meta( self::$post_id, 'unique_update', true ) ); @@ -242,7 +245,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { $funky_meta[] = $classy; // Add a post meta item. - $this->assertInternalType( 'integer', add_post_meta( self::$post_id, 'test_funky_post_meta', $funky_meta, true ) ); + $this->assertIsInt( add_post_meta( self::$post_id, 'test_funky_post_meta', $funky_meta, true ) ); // Check it exists. $this->assertEquals( $funky_meta, get_post_meta( self::$post_id, 'test_funky_post_meta', true ) ); @@ -318,7 +321,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { wp_cache_delete( 'last_changed', 'posts' ); - $this->assertInternalType( 'integer', add_metadata( 'post', $post_id, 'foo', 'bar' ) ); + $this->assertIsInt( add_metadata( 'post', $post_id, 'foo', 'bar' ) ); $this->assertNotFalse( wp_cache_get_last_changed( 'posts' ) ); } @@ -330,7 +333,7 @@ class Tests_Post_Meta extends WP_UnitTestCase { wp_cache_delete( 'last_changed', 'posts' ); - $this->assertInternalType( 'integer', update_metadata( 'post', $post_id, 'foo', 'bar' ) ); + $this->assertIsInt( update_metadata( 'post', $post_id, 'foo', 'bar' ) ); $this->assertNotFalse( wp_cache_get_last_changed( 'posts' ) ); } diff --git a/tests/phpunit/tests/post/objects.php b/tests/phpunit/tests/post/objects.php index 0cb653c577..6c2f213fab 100644 --- a/tests/phpunit/tests/post/objects.php +++ b/tests/phpunit/tests/post/objects.php @@ -30,17 +30,17 @@ class Tests_Post_Objects extends WP_UnitTestCase { // Excercise the output argument. $post = get_post( $id, ARRAY_A ); - $this->assertInternalType( 'array', $post ); + $this->assertIsArray( $post ); $this->assertSame( 'post', $post['post_type'] ); $post = get_post( $id, ARRAY_N ); - $this->assertInternalType( 'array', $post ); + $this->assertIsArray( $post ); $this->assertFalse( isset( $post['post_type'] ) ); $this->assertTrue( in_array( 'post', $post, true ) ); $post = get_post( $id ); $post = get_post( $post, ARRAY_A ); - $this->assertInternalType( 'array', $post ); + $this->assertIsArray( $post ); $this->assertSame( 'post', $post['post_type'] ); $this->assertSame( $id, $post['ID'] ); @@ -51,7 +51,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { // Make sure stdClass in $GLOBALS['post'] is handled. $post_std = $post->to_array(); - $this->assertInternalType( 'array', $post_std ); + $this->assertIsArray( $post_std ); $post_std = (object) $post_std; $GLOBALS['post'] = $post_std; $post = get_post( null ); @@ -103,7 +103,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { */ function test_get_post_ancestors_with_falsey_values() { foreach ( array( null, 0, false, '0', '' ) as $post_id ) { - $this->assertInternalType( 'array', get_post_ancestors( $post_id ) ); + $this->assertIsArray( get_post_ancestors( $post_id ) ); $this->assertSame( array(), get_post_ancestors( $post_id ) ); } } @@ -112,7 +112,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post_id = self::factory()->post->create(); $post = get_post( $post_id ); - $this->assertInternalType( 'array', $post->post_category ); + $this->assertIsArray( $post->post_category ); $this->assertSame( 1, count( $post->post_category ) ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); $term1 = wp_insert_term( 'Foo', 'category' ); @@ -131,15 +131,15 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post_id = self::factory()->post->create(); $post = get_post( $post_id ); - $this->assertInternalType( 'array', $post->tags_input ); + $this->assertIsArray( $post->tags_input ); $this->assertEmpty( $post->tags_input ); wp_set_post_tags( $post_id, 'Foo, Bar, Baz' ); - $this->assertInternalType( 'array', $post->tags_input ); + $this->assertIsArray( $post->tags_input ); $this->assertSame( 3, count( $post->tags_input ) ); $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post->tags_input ); $post = get_post( $post_id, ARRAY_A ); - $this->assertInternalType( 'array', $post['tags_input'] ); + $this->assertIsArray( $post['tags_input'] ); $this->assertSame( 3, count( $post['tags_input'] ) ); $this->assertSame( array( 'Bar', 'Baz', 'Foo' ), $post['tags_input'] ); } @@ -148,7 +148,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { $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->assertSame( $template, $post->page_template ); update_post_meta( $post_id, '_wp_page_template', 'foo.php' ); @@ -167,7 +167,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { ); $this->assertSame( 'raw', $post->filter ); - $this->assertInternalType( 'int', $post->post_parent ); + $this->assertIsInt( $post->post_parent ); $display_post = get_post( $post, OBJECT, 'js' ); $this->assertSame( 'js', $display_post->filter ); @@ -194,9 +194,9 @@ class Tests_Post_Objects extends WP_UnitTestCase { foreach ( $contexts as $context ) { $post = get_post( $post_id, OBJECT, $context ); - $this->assertInternalType( 'int', $post->ID ); - $this->assertInternalType( 'int', $post->post_parent ); - $this->assertInternalType( 'int', $post->menu_order ); + $this->assertIsInt( $post->ID ); + $this->assertIsInt( $post->post_parent ); + $this->assertIsInt( $post->menu_order ); } } @@ -215,7 +215,7 @@ class Tests_Post_Objects extends WP_UnitTestCase { $post = get_post( $id, ARRAY_A ); $this->assertSame( $id, $post['ID'] ); - $this->assertInternalType( 'array', $post['ancestors'] ); + $this->assertIsArray( $post['ancestors'] ); $this->assertSame( 'raw', $post['filter'] ); } diff --git a/tests/phpunit/tests/post/query.php b/tests/phpunit/tests/post/query.php index 1c6e30faf9..df72bdbe25 100644 --- a/tests/phpunit/tests/post/query.php +++ b/tests/phpunit/tests/post/query.php @@ -737,7 +737,7 @@ class Tests_Post_Query extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'int', $q->found_posts ); + $this->assertIsInt( $q->found_posts ); } /** @@ -756,6 +756,6 @@ class Tests_Post_Query extends WP_UnitTestCase { remove_filter( 'found_posts', '__return_empty_string' ); - $this->assertInternalType( 'int', $q->found_posts ); + $this->assertIsInt( $q->found_posts ); } } diff --git a/tests/phpunit/tests/post/types.php b/tests/phpunit/tests/post/types.php index 9090f865c9..db0283bb0d 100644 --- a/tests/phpunit/tests/post/types.php +++ b/tests/phpunit/tests/post/types.php @@ -321,7 +321,7 @@ class Tests_Post_Types extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars, true ) ); + $this->assertIsInt( array_search( 'bar', $wp->public_query_vars, true ) ); $this->assertTrue( unregister_post_type( 'foo' ) ); $this->assertFalse( array_search( 'bar', $wp->public_query_vars, true ) ); } @@ -439,8 +439,8 @@ class Tests_Post_Types extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'int', array_search( 'foo', $wp_taxonomies['category']->object_type, true ) ); - $this->assertInternalType( 'int', array_search( 'foo', $wp_taxonomies['post_tag']->object_type, true ) ); + $this->assertIsInt( array_search( 'foo', $wp_taxonomies['category']->object_type, true ) ); + $this->assertIsInt( array_search( 'foo', $wp_taxonomies['post_tag']->object_type, true ) ); $this->assertTrue( unregister_post_type( 'foo' ) ); $this->assertFalse( array_search( 'foo', $wp_taxonomies['category']->object_type, true ) ); $this->assertFalse( array_search( 'foo', $wp_taxonomies['post_tag']->object_type, true ) ); @@ -499,8 +499,8 @@ class Tests_Post_Types extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'object', $wp_post_types['foo'] ); - $this->assertInternalType( 'object', get_post_type_object( 'foo' ) ); + $this->assertIsObject( $wp_post_types['foo'] ); + $this->assertIsObject( get_post_type_object( 'foo' ) ); $this->assertTrue( unregister_post_type( 'foo' ) ); diff --git a/tests/phpunit/tests/query/results.php b/tests/phpunit/tests/query/results.php index 80bfc5e379..d2ce5dd209 100644 --- a/tests/phpunit/tests/query/results.php +++ b/tests/phpunit/tests/query/results.php @@ -765,8 +765,8 @@ class Tests_Query_Results extends WP_UnitTestCase { $this->assertSame( $children, $posts2 ); foreach ( $this->q->posts as $post ) { - $this->assertInternalType( 'int', $post->ID ); - $this->assertInternalType( 'int', $post->post_parent ); + $this->assertIsInt( $post->ID ); + $this->assertIsInt( $post->post_parent ); } } diff --git a/tests/phpunit/tests/rest-api/rest-attachments-controller.php b/tests/phpunit/tests/rest-api/rest-attachments-controller.php index 16cbcb61c8..195445aa44 100644 --- a/tests/phpunit/tests/rest-api/rest-attachments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-attachments-controller.php @@ -658,7 +658,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control $original_image_src = wp_get_attachment_image_src( $attachment_id, 'full' ); remove_image_size( 'rest-api-test' ); - $this->assertInternalType( 'array', $data['media_details']['sizes'], 'Could not retrieve the sizes data.' ); + $this->assertIsArray( $data['media_details']['sizes'], 'Could not retrieve the sizes data.' ); $this->assertSame( $image_src[0], $data['media_details']['sizes']['rest-api-test']['source_url'] ); $this->assertSame( 'image/jpeg', $data['media_details']['sizes']['rest-api-test']['mime_type'] ); $this->assertSame( $original_image_src[0], $data['media_details']['sizes']['full']['source_url'] ); @@ -690,7 +690,7 @@ class WP_Test_REST_Attachments_Controller extends WP_Test_REST_Post_Type_Control remove_filter( 'wp_get_attachment_image_src', '__return_false' ); remove_image_size( 'rest-api-test' ); - $this->assertInternalType( 'array', $data['media_details']['sizes'], 'Could not retrieve the sizes data.' ); + $this->assertIsArray( $data['media_details']['sizes'], 'Could not retrieve the sizes data.' ); $this->assertFalse( isset( $data['media_details']['sizes']['rest-api-test']['source_url'] ) ); } diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 5451e12533..3c1b1a2f2a 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -2903,7 +2903,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase $actual_output = $response->get_data(); // Compare expected API output to actual API output. - $this->assertInternalType( 'array', $actual_output['content'] ); + $this->assertIsArray( $actual_output['content'] ); $this->assertArrayHasKey( 'raw', $actual_output['content'] ); $this->assertSame( $expected_output['content']['raw'], $actual_output['content']['raw'] ); $this->assertSame( $expected_output['content']['rendered'], trim( $actual_output['content']['rendered'] ) ); 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 2b75162976..ec73681a79 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -290,7 +290,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_multi', $meta ); - $this->assertInternalType( 'array', $meta['test_multi'] ); + $this->assertIsArray( $meta['test_multi'] ); $this->assertContains( 'value1', $meta['test_multi'] ); // Check after an update. @@ -395,15 +395,15 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $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 ); - $this->assertInternalType( 'float', $meta['test_number'] ); + $this->assertIsFloat( $meta['test_number'] ); $this->assertSame( 42.0, $meta['test_number'] ); $this->assertArrayHasKey( 'test_bool', $meta ); - $this->assertInternalType( 'boolean', $meta['test_bool'] ); + $this->assertIsBool( $meta['test_bool'] ); $this->assertTrue( $meta['test_bool'] ); } @@ -1272,7 +1272,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); - $this->assertInternalType( 'array', $data['meta'] ); + $this->assertIsArray( $data['meta'] ); if ( $in_post_type ) { $expected_value = $meta_value; @@ -1338,7 +1338,7 @@ class WP_Test_REST_Post_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); - $this->assertInternalType( 'array', $data['meta'] ); + $this->assertIsArray( $data['meta'] ); if ( $in_post_type ) { $expected_value = $meta_value; diff --git a/tests/phpunit/tests/rest-api/rest-request.php b/tests/phpunit/tests/rest-api/rest-request.php index 9fca2662be..cf6678d4f7 100644 --- a/tests/phpunit/tests/rest-api/rest-request.php +++ b/tests/phpunit/tests/rest-api/rest-request.php @@ -491,7 +491,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->assertWPError( $valid ); $data = $valid->get_error_data(); - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertArrayHasKey( 'params', $data ); $this->assertArrayHasKey( 'failparam', $data['params'] ); $this->assertSame( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] ); @@ -754,7 +754,7 @@ class Tests_REST_Request extends WP_UnitTestCase { $this->assertWPError( $valid ); $data = $valid->get_error_data(); - $this->assertInternalType( 'array', $data ); + $this->assertIsArray( $data ); $this->assertArrayHasKey( 'params', $data ); $this->assertArrayHasKey( 'failparam', $data['params'] ); $this->assertSame( 'Invalid. Super Invalid. Broken.', $data['params']['failparam'] ); diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index adb2334046..999ae6349c 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -545,7 +545,7 @@ class Tests_REST_Server extends WP_Test_REST_TestCase { $this->assertCount( 2, $alternate ); $this->assertEmpty( $alternate[0] ); - $this->assertInternalType( 'array', $alternate[1] ); + $this->assertIsArray( $alternate[1] ); $this->assertArrayNotHasKey( 'code', $alternate[1] ); $this->assertTrue( $alternate[1]['hello'] ); 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 8ed2a0a26f..a17b813f9b 100644 --- a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php @@ -237,7 +237,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $meta = (array) $data['meta']; $this->assertArrayHasKey( 'test_multi', $meta ); - $this->assertInternalType( 'array', $meta['test_multi'] ); + $this->assertIsArray( $meta['test_multi'] ); $this->assertContains( 'value1', $meta['test_multi'] ); // Check after an update. @@ -342,15 +342,15 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $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 ); - $this->assertInternalType( 'float', $meta['test_number'] ); + $this->assertIsFloat( $meta['test_number'] ); $this->assertSame( 42.0, $meta['test_number'] ); $this->assertArrayHasKey( 'test_bool', $meta ); - $this->assertInternalType( 'boolean', $meta['test_bool'] ); + $this->assertIsBool( $meta['test_bool'] ); $this->assertTrue( $meta['test_bool'] ); } @@ -1157,7 +1157,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); - $this->assertInternalType( 'array', $data['meta'] ); + $this->assertIsArray( $data['meta'] ); if ( $in_taxonomy ) { $expected_value = $meta_value; @@ -1221,7 +1221,7 @@ class WP_Test_REST_Term_Meta_Fields extends WP_Test_REST_TestCase { $data = $response->get_data(); $this->assertArrayHasKey( 'meta', $data ); - $this->assertInternalType( 'array', $data['meta'] ); + $this->assertIsArray( $data['meta'] ); if ( $in_taxonomy ) { $expected_value = $meta_value; diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php index 7897d10d1d..0ac38bba62 100644 --- a/tests/phpunit/tests/rest-api/rest-users-controller.php +++ b/tests/phpunit/tests/rest-api/rest-users-controller.php @@ -1211,15 +1211,15 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $data = $response->get_data(); if ( is_multisite() ) { - $this->assertInternalType( 'array', $data['additional_errors'] ); + $this->assertIsArray( $data['additional_errors'] ); $this->assertCount( 1, $data['additional_errors'] ); $error = $data['additional_errors'][0]; $this->assertSame( 'user_name', $error['code'] ); $this->assertSame( 'Usernames can only contain lowercase letters (a-z) and numbers.', $error['message'] ); } else { - $this->assertInternalType( 'array', $data['data']['params'] ); + $this->assertIsArray( $data['data']['params'] ); $errors = $data['data']['params']; - $this->assertInternalType( 'string', $errors['username'] ); + $this->assertIsString( $errors['username'] ); $this->assertSame( 'This username is invalid because it uses illegal characters. Please enter a valid username.', $errors['username'] ); } } @@ -1257,9 +1257,9 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); $data = $response->get_data(); - $this->assertInternalType( 'array', $data['data']['params'] ); + $this->assertIsArray( $data['data']['params'] ); $errors = $data['data']['params']; - $this->assertInternalType( 'string', $errors['username'] ); + $this->assertIsString( $errors['username'] ); $this->assertSame( 'Sorry, that username is not allowed.', $errors['username'] ); } @@ -1381,7 +1381,7 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { $this->assertErrorResponse( 'rest_invalid_param', $switched_response, 400 ); $data = $switched_response->get_data(); - $this->assertInternalType( 'array', $data['additional_errors'] ); + $this->assertIsArray( $data['additional_errors'] ); $this->assertCount( 2, $data['additional_errors'] ); $errors = $data['additional_errors']; foreach ( $errors as $error ) { diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index 0b653f9d28..a6b99ab4b9 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -482,7 +482,7 @@ class Tests_Rewrite extends WP_UnitTestCase { $this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' ); $rewrite_rules = get_option( 'rewrite_rules' ); - $this->assertInternalType( 'array', $rewrite_rules ); + $this->assertIsArray( $rewrite_rules ); $this->assertNotEmpty( $rewrite_rules ); } } diff --git a/tests/phpunit/tests/rewrite/permastructs.php b/tests/phpunit/tests/rewrite/permastructs.php index 548f64bbfd..1605b2c00d 100644 --- a/tests/phpunit/tests/rewrite/permastructs.php +++ b/tests/phpunit/tests/rewrite/permastructs.php @@ -34,7 +34,7 @@ class Tests_Rewrite_Permastructs extends WP_UnitTestCase { global $wp_rewrite; add_permastruct( 'foo', 'bar/%foo%' ); - $this->assertInternalType( 'array', $wp_rewrite->extra_permastructs['foo'] ); + $this->assertIsArray( $wp_rewrite->extra_permastructs['foo'] ); $this->assertSame( '/bar/%foo%', $wp_rewrite->extra_permastructs['foo']['struct'] ); remove_permastruct( 'foo' ); diff --git a/tests/phpunit/tests/taxonomy.php b/tests/phpunit/tests/taxonomy.php index 652ac96cd6..21224d82e2 100644 --- a/tests/phpunit/tests/taxonomy.php +++ b/tests/phpunit/tests/taxonomy.php @@ -818,7 +818,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_taxonomy( 'foo', 'post', array( 'query_var' => 'bar' ) ); - $this->assertInternalType( 'int', array_search( 'bar', $wp->public_query_vars, true ) ); + $this->assertIsInt( array_search( 'bar', $wp->public_query_vars, true ) ); $this->assertTrue( unregister_taxonomy( 'foo' ) ); $this->assertFalse( array_search( 'bar', $wp->public_query_vars, true ) ); } @@ -840,7 +840,7 @@ class Tests_Taxonomy extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'array', $wp_rewrite->extra_permastructs['foo'] ); + $this->assertIsArray( $wp_rewrite->extra_permastructs['foo'] ); $this->assertTrue( unregister_taxonomy( 'foo' ) ); $this->assertFalse( isset( $wp_rewrite->extra_permastructs['foo'] ) ); } @@ -873,8 +873,8 @@ class Tests_Taxonomy extends WP_UnitTestCase { register_taxonomy( 'foo', 'post' ); - $this->assertInternalType( 'object', $wp_taxonomies['foo'] ); - $this->assertInternalType( 'object', get_taxonomy( 'foo' ) ); + $this->assertIsObject( $wp_taxonomies['foo'] ); + $this->assertIsObject( get_taxonomy( 'foo' ) ); $this->assertTrue( unregister_taxonomy( 'foo' ) ); diff --git a/tests/phpunit/tests/taxonomy/getObjectTaxonomies.php b/tests/phpunit/tests/taxonomy/getObjectTaxonomies.php index f57e910ed4..b38f3f994c 100644 --- a/tests/phpunit/tests/taxonomy/getObjectTaxonomies.php +++ b/tests/phpunit/tests/taxonomy/getObjectTaxonomies.php @@ -36,7 +36,7 @@ class Tests_Taxonomy_GetObjectTaxonomies extends WP_UnitTestCase { $found = get_object_taxonomies( 'wptests_pt', 'objects' ); $this->assertSame( array( 'wptests_tax' ), array_keys( $found ) ); - $this->assertInternalType( 'object', $found['wptests_tax'] ); + $this->assertIsObject( $found['wptests_tax'] ); $this->assertSame( 'wptests_tax', $found['wptests_tax']->name ); } @@ -87,7 +87,7 @@ class Tests_Taxonomy_GetObjectTaxonomies extends WP_UnitTestCase { $found = get_object_taxonomies( $attachment, 'objects' ); $this->assertSame( array( 'wptests_tax2' ), array_keys( $found ) ); - $this->assertInternalType( 'object', $found['wptests_tax2'] ); + $this->assertIsObject( $found['wptests_tax2'] ); $this->assertSame( 'wptests_tax2', $found['wptests_tax2']->name ); } } diff --git a/tests/phpunit/tests/term.php b/tests/phpunit/tests/term.php index 4808e47d72..2525a8c53f 100644 --- a/tests/phpunit/tests/term.php +++ b/tests/phpunit/tests/term.php @@ -53,7 +53,7 @@ class Tests_Term extends WP_UnitTestCase { // Insert a term. $term = rand_str(); $t = wp_insert_term( $term, $this->taxonomy ); - $this->assertInternalType( 'array', $t ); + $this->assertIsArray( $t ); $term_obj = get_term_by( 'name', $term, $this->taxonomy ); $this->assertEquals( $t['term_id'], term_exists( $term_obj->slug ) ); @@ -132,9 +132,9 @@ class Tests_Term extends WP_UnitTestCase { $term2 = rand_str(); $t = wp_insert_term( $term, 'category' ); - $this->assertInternalType( 'array', $t ); + $this->assertIsArray( $t ); $t2 = wp_insert_term( $term, 'category', array( 'parent' => $t['term_id'] ) ); - $this->assertInternalType( 'array', $t2 ); + $this->assertIsArray( $t2 ); if ( function_exists( 'term_is_ancestor_of' ) ) { $this->assertTrue( term_is_ancestor_of( $t['term_id'], $t2['term_id'], 'category' ) ); $this->assertFalse( term_is_ancestor_of( $t2['term_id'], $t['term_id'], 'category' ) ); @@ -176,7 +176,7 @@ class Tests_Term extends WP_UnitTestCase { $post_id = self::$post_ids[0]; $post = get_post( $post_id ); - $this->assertInternalType( 'array', $post->post_category ); + $this->assertIsArray( $post->post_category ); $this->assertSame( 1, count( $post->post_category ) ); $this->assertEquals( get_option( 'default_category' ), $post->post_category[0] ); diff --git a/tests/phpunit/tests/term/getTerm.php b/tests/phpunit/tests/term/getTerm.php index c9fc2bae1d..d2aef46e9a 100644 --- a/tests/phpunit/tests/term/getTerm.php +++ b/tests/phpunit/tests/term/getTerm.php @@ -97,29 +97,29 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { public function test_output_object() { $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', OBJECT ) ); + $this->assertIsObject( get_term( $t, 'wptests_tax', OBJECT ) ); } public function test_output_array_a() { $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $term = get_term( $t, 'wptests_tax', ARRAY_A ); - $this->assertInternalType( 'array', $term ); + $this->assertIsArray( $term ); $this->assertTrue( isset( $term['term_id'] ) ); } public function test_output_array_n() { $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $term = get_term( $t, 'wptests_tax', ARRAY_N ); - $this->assertInternalType( 'array', $term ); + $this->assertIsArray( $term ); $this->assertFalse( isset( $term['term_id'] ) ); foreach ( $term as $k => $v ) { - $this->assertInternalType( 'integer', $k ); + $this->assertIsInt( $k ); } } public function test_output_should_fall_back_to_object_for_invalid_input() { $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); - $this->assertInternalType( 'object', get_term( $t, 'wptests_tax', 'foo' ) ); + $this->assertIsObject( get_term( $t, 'wptests_tax', 'foo' ) ); } /** @@ -140,11 +140,11 @@ class Tests_Term_GetTerm extends WP_UnitTestCase { $found = get_term( $term_data, '', OBJECT, $context ); $this->assertInstanceOf( 'WP_Term', $found ); - $this->assertInternalType( 'int', $found->term_id ); - $this->assertInternalType( 'int', $found->term_taxonomy_id ); - $this->assertInternalType( 'int', $found->parent ); - $this->assertInternalType( 'int', $found->count ); - $this->assertInternalType( 'int', $found->term_group ); + $this->assertIsInt( $found->term_id ); + $this->assertIsInt( $found->term_taxonomy_id ); + $this->assertIsInt( $found->parent ); + $this->assertIsInt( $found->count ); + $this->assertIsInt( $found->term_group ); } } diff --git a/tests/phpunit/tests/term/getTerms.php b/tests/phpunit/tests/term/getTerms.php index cb17e84238..d42dd44099 100644 --- a/tests/phpunit/tests/term/getTerms.php +++ b/tests/phpunit/tests/term/getTerms.php @@ -861,7 +861,7 @@ class Tests_Term_getTerms extends WP_UnitTestCase { $term = get_term( $term['term_id'], 'category' ); $this->assertSame( $term->term_id, $term->parent ); - $this->assertInternalType( 'array', get_term_children( $term->term_id, 'category' ) ); + $this->assertIsArray( get_term_children( $term->term_id, 'category' ) ); add_filter( 'wp_update_term_parent', 'wp_check_term_hierarchy_for_loops', 10, 3 ); } diff --git a/tests/phpunit/tests/term/getTheTerms.php b/tests/phpunit/tests/term/getTheTerms.php index a28411405a..43990431c7 100644 --- a/tests/phpunit/tests/term/getTheTerms.php +++ b/tests/phpunit/tests/term/getTheTerms.php @@ -39,7 +39,7 @@ class Tests_Term_GetTheTerms extends WP_UnitTestCase { // get_the_terms() does prime the cache. $terms = get_the_terms( $post_id, $this->taxonomy ); $cache = wp_cache_get( $post_id, $this->taxonomy . '_relationships' ); - $this->assertInternalType( 'array', $cache ); + $this->assertIsArray( $cache ); // Cache should be empty after a set. $tt_2 = wp_set_object_terms( $post_id, $terms_2, $this->taxonomy ); diff --git a/tests/phpunit/tests/term/meta.php b/tests/phpunit/tests/term/meta.php index efde245153..f821a67511 100644 --- a/tests/phpunit/tests/term/meta.php +++ b/tests/phpunit/tests/term/meta.php @@ -94,7 +94,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { $t = self::factory()->term->create( array( 'taxonomy' => 'wptests_tax' ) ); $actual = update_term_meta( $t, 'foo', 'bar' ); - $this->assertInternalType( 'int', $actual ); + $this->assertIsInt( $actual ); $this->assertNotEmpty( $actual ); $meta = get_term_meta( $t, 'foo', true ); @@ -549,7 +549,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { wp_cache_delete( 'last_changed', 'terms' ); - $this->assertInternalType( 'integer', add_metadata( 'term', $term_id, 'foo', 'bar' ) ); + $this->assertIsInt( add_metadata( 'term', $term_id, 'foo', 'bar' ) ); $this->assertNotFalse( wp_cache_get_last_changed( 'terms' ) ); } @@ -561,7 +561,7 @@ class Tests_Term_Meta extends WP_UnitTestCase { wp_cache_delete( 'last_changed', 'terms' ); - $this->assertInternalType( 'integer', update_metadata( 'term', $term_id, 'foo', 'bar' ) ); + $this->assertIsInt( update_metadata( 'term', $term_id, 'foo', 'bar' ) ); $this->assertNotFalse( wp_cache_get_last_changed( 'terms' ) ); } diff --git a/tests/phpunit/tests/term/termExists.php b/tests/phpunit/tests/term/termExists.php index 8f39385e40..8b57d67cd9 100644 --- a/tests/phpunit/tests/term/termExists.php +++ b/tests/phpunit/tests/term/termExists.php @@ -116,7 +116,7 @@ class Tests_TermExists extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'array', $found ); + $this->assertIsArray( $found ); $this->assertEquals( $t, $found['term_id'] ); } @@ -180,7 +180,7 @@ class Tests_TermExists extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'array', $found ); + $this->assertIsArray( $found ); $this->assertEquals( $t, $found['term_id'] ); } @@ -198,7 +198,7 @@ class Tests_TermExists extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'array', $found ); + $this->assertIsArray( $found ); $this->assertEquals( $t, $found['term_id'] ); } @@ -216,7 +216,7 @@ class Tests_TermExists extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'array', $found ); + $this->assertIsArray( $found ); $this->assertEquals( $t, $found['term_id'] ); } @@ -234,7 +234,7 @@ class Tests_TermExists extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'string', $found ); + $this->assertIsString( $found ); $this->assertEquals( $t, $found ); } @@ -252,7 +252,7 @@ class Tests_TermExists extends WP_UnitTestCase { _unregister_taxonomy( 'foo' ); - $this->assertInternalType( 'string', $found ); + $this->assertIsString( $found ); $this->assertEquals( $t, $found ); } @@ -262,7 +262,7 @@ class Tests_TermExists extends WP_UnitTestCase { // Insert a term. $term = rand_str(); $t = wp_insert_term( $term, 'wptests_tax' ); - $this->assertInternalType( 'array', $t ); + $this->assertIsArray( $t ); $this->assertEquals( $t['term_id'], term_exists( $t['term_id'] ) ); $this->assertEquals( $t['term_id'], term_exists( $term ) ); diff --git a/tests/phpunit/tests/term/wpGenerateTagCloud.php b/tests/phpunit/tests/term/wpGenerateTagCloud.php index dec65d440e..eecce41fe0 100644 --- a/tests/phpunit/tests/term/wpGenerateTagCloud.php +++ b/tests/phpunit/tests/term/wpGenerateTagCloud.php @@ -106,7 +106,7 @@ class Tests_WP_Generate_Tag_Cloud extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'array', $found ); + $this->assertIsArray( $found ); $this->assertContains( '>' . $tags[0]->name . '<', $found[0] ); } diff --git a/tests/phpunit/tests/term/wpGetObjectTerms.php b/tests/phpunit/tests/term/wpGetObjectTerms.php index 53bbf22de9..7e2aa0cd30 100644 --- a/tests/phpunit/tests/term/wpGetObjectTerms.php +++ b/tests/phpunit/tests/term/wpGetObjectTerms.php @@ -73,12 +73,12 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { $term = array_shift( $terms ); $int_fields = array( 'parent', 'term_id', 'count', 'term_group', 'term_taxonomy_id', 'object_id' ); foreach ( $int_fields as $field ) { - $this->assertInternalType( 'int', $term->$field, $field ); + $this->assertIsInt( $term->$field, $field ); } $terms = wp_get_object_terms( $post_id, $this->taxonomy, array( 'fields' => 'ids' ) ); $term = array_shift( $terms ); - $this->assertInternalType( 'int', $term, 'term' ); + $this->assertIsInt( $term, 'term' ); } /** @@ -93,7 +93,7 @@ class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase { $terms = wp_get_object_terms( $post_id, $this->taxonomy ); remove_filter( 'wp_get_object_terms', array( $this, 'filter_get_object_terms' ) ); foreach ( $terms as $term ) { - $this->assertInternalType( 'object', $term ); + $this->assertIsObject( $term ); } } diff --git a/tests/phpunit/tests/term/wpInsertTerm.php b/tests/phpunit/tests/term/wpInsertTerm.php index 8fd3504650..3a7d637d8c 100644 --- a/tests/phpunit/tests/term/wpInsertTerm.php +++ b/tests/phpunit/tests/term/wpInsertTerm.php @@ -27,7 +27,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { $initial_count = wp_count_terms( array( 'taxonomy' => $taxonomy ) ); $t = wp_insert_term( $term, $taxonomy ); - $this->assertInternalType( 'array', $t ); + $this->assertIsArray( $t ); $this->assertNotWPError( $t ); $this->assertTrue( $t['term_id'] > 0 ); $this->assertTrue( $t['term_taxonomy_id'] > 0 ); @@ -776,7 +776,7 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { _unregister_taxonomy( 'wptests_tax' ); - $this->assertInternalType( 'array', $found ); + $this->assertIsArray( $found ); $this->assertNotEmpty( $found['term_id'] ); $this->assertNotEmpty( $found['term_taxonomy_id'] ); $this->assertNotEmpty( $term_by_id ); @@ -844,8 +844,8 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'int', $t1 ); - $this->assertInternalType( 'int', $t2 ); + $this->assertIsInt( $t1 ); + $this->assertIsInt( $t2 ); $this->assertNotEquals( $t1, $t2 ); $term_2 = get_term( $t2, 'wptests_tax' ); @@ -900,10 +900,10 @@ class Tests_Term_WpInsertTerm extends WP_UnitTestCase { /** Helpers */ public function deleted_term_cb( $term, $tt_id, $taxonomy, $deleted_term, $object_ids ) { - $this->assertInternalType( 'object', $deleted_term ); - $this->assertInternalType( 'int', $term ); - $this->assertInternalType( 'array', $object_ids ); - // Pesky string $this->assertInternalType( 'int', $tt_id ); + $this->assertIsObject( $deleted_term ); + $this->assertIsInt( $term ); + $this->assertIsArray( $object_ids ); + // Pesky string $this->assertIsInt( $tt_id ); $this->assertSame( $term, $deleted_term->term_id ); $this->assertSame( $taxonomy, $deleted_term->taxonomy ); $this->assertEquals( $tt_id, $deleted_term->term_taxonomy_id ); diff --git a/tests/phpunit/tests/term/wpSetObjectTerms.php b/tests/phpunit/tests/term/wpSetObjectTerms.php index df35ab1783..024d2e9449 100644 --- a/tests/phpunit/tests/term/wpSetObjectTerms.php +++ b/tests/phpunit/tests/term/wpSetObjectTerms.php @@ -106,7 +106,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { for ( $i = 0; $i < 3; $i++ ) { $term = "term_{$i}"; $result = wp_insert_term( $term, $this->taxonomy ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $term_id[ $term ] = $result['term_id']; } @@ -254,7 +254,7 @@ class Tests_Term_WpSetObjectTerms extends WP_UnitTestCase { for ( $i = 0; $i < 3; $i++ ) { $term = "term_{$i}"; $result = wp_insert_term( $term, $this->taxonomy ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $terms_1[ $i ] = $result['term_id']; } diff --git a/tests/phpunit/tests/term/wpUpdateTerm.php b/tests/phpunit/tests/term/wpUpdateTerm.php index 2f4b23120d..3cd74aa5ac 100644 --- a/tests/phpunit/tests/term/wpUpdateTerm.php +++ b/tests/phpunit/tests/term/wpUpdateTerm.php @@ -612,7 +612,7 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { _unregister_taxonomy( 'wptests_tax' ); - $this->assertInternalType( 'array', $found ); + $this->assertIsArray( $found ); $this->assertNotEmpty( $found['term_id'] ); $this->assertNotEmpty( $found['term_taxonomy_id'] ); $this->assertNotEmpty( $term_by_id ); @@ -638,8 +638,8 @@ class Tests_Term_WpUpdateTerm extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'int', $found['term_id'] ); - $this->assertInternalType( 'int', $found['term_taxonomy_id'] ); + $this->assertIsInt( $found['term_id'] ); + $this->assertIsInt( $found['term_taxonomy_id'] ); } public function test_wp_update_term_should_clean_term_cache() { diff --git a/tests/phpunit/tests/theme/getThemeStarterContent.php b/tests/phpunit/tests/theme/getThemeStarterContent.php index 0ab6ad84ab..df59f83e17 100644 --- a/tests/phpunit/tests/theme/getThemeStarterContent.php +++ b/tests/phpunit/tests/theme/getThemeStarterContent.php @@ -142,25 +142,25 @@ class Tests_Theme_GetThemeStarterContent extends WP_UnitTestCase { $this->assertSame( $dehydrated_starter_content['attachments']['featured-image-logo'], $hydrated_starter_content['attachments']['featured-image-logo'] ); foreach ( $hydrated_starter_content['widgets']['sidebar-1'] as $widget ) { - $this->assertInternalType( 'array', $widget ); + $this->assertIsArray( $widget ); $this->assertCount( 2, $widget ); - $this->assertInternalType( 'string', $widget[0] ); - $this->assertInternalType( 'array', $widget[1] ); + $this->assertIsString( $widget[0] ); + $this->assertIsArray( $widget[1] ); $this->assertArrayHasKey( 'title', $widget[1] ); } $this->assertSame( 'text', $hydrated_starter_content['widgets']['sidebar-1'][1][0], 'Core content extended' ); $this->assertSame( 'Our Story', $hydrated_starter_content['widgets']['sidebar-1'][1][1]['title'], 'Core content extended' ); foreach ( $hydrated_starter_content['nav_menus']['top']['items'] as $nav_menu_item ) { - $this->assertInternalType( 'array', $nav_menu_item ); + $this->assertIsArray( $nav_menu_item ); $this->assertTrue( ! empty( $nav_menu_item['object_id'] ) || ! empty( $nav_menu_item['url'] ) ); } $this->assertSame( '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->assertInternalType( 'array', $post ); + $this->assertIsArray( $post ); $this->assertArrayHasKey( 'post_type', $post ); $this->assertArrayHasKey( 'post_title', $post ); } @@ -200,7 +200,7 @@ class Tests_Theme_GetThemeStarterContent extends WP_UnitTestCase { * @return array Filtered starter content. */ public function filter_theme_starter_content( $content, $config ) { - $this->assertInternalType( 'array', $config ); + $this->assertIsArray( $config ); $this->assertCount( 1, $config['widgets']['sidebar-1'] ); $content['widgets']['sidebar-1'][] = array( 'text', diff --git a/tests/phpunit/tests/user.php b/tests/phpunit/tests/user.php index 47ad79e233..1917c3a54c 100644 --- a/tests/phpunit/tests/user.php +++ b/tests/phpunit/tests/user.php @@ -216,7 +216,7 @@ class Tests_User extends WP_UnitTestCase { $user->filter = $context; $user->init( $user->data ); - $this->assertInternalType( 'int', $user->ID ); + $this->assertIsInt( $user->ID ); } } @@ -870,7 +870,7 @@ class Tests_User extends WP_UnitTestCase { ) ); - $this->assertInternalType( 'int', $u ); + $this->assertIsInt( $u ); $this->assertGreaterThan( 0, $u ); $user = new WP_User( $u ); @@ -1493,7 +1493,7 @@ class Tests_User extends WP_UnitTestCase { $user_id = edit_user(); $user = get_user_by( 'ID', $user_id ); - $this->assertInternalType( 'int', $user_id ); + $this->assertIsInt( $user_id ); $this->assertInstanceOf( 'WP_User', $user ); $this->assertSame( 'nickname1', $user->nickname ); @@ -1504,7 +1504,7 @@ class Tests_User extends WP_UnitTestCase { $user_id = edit_user( $user_id ); - $this->assertInternalType( 'int', $user_id ); + $this->assertIsInt( $user_id ); $this->assertSame( 'nickname_updated', $user->nickname ); // Check not to change an old password if a new password contains only spaces. Ticket #42766. @@ -1516,7 +1516,7 @@ class Tests_User extends WP_UnitTestCase { $user_id = edit_user( $user_id ); $user = get_user_by( 'ID', $user_id ); - $this->assertInternalType( 'int', $user_id ); + $this->assertIsInt( $user_id ); $this->assertSame( $old_pass, $user->user_pass ); // Check updating user with missing second password. @@ -1535,7 +1535,7 @@ class Tests_User extends WP_UnitTestCase { $user_id = edit_user( $user_id ); remove_action( 'check_passwords', array( $this, 'action_check_passwords_blank_password' ) ); - $this->assertInternalType( 'int', $user_id ); + $this->assertIsInt( $user_id ); $this->assertSame( 'nickname_updated2', $user->nickname ); } diff --git a/tests/phpunit/tests/user/multisite.php b/tests/phpunit/tests/user/multisite.php index be74597277..89daba1b29 100644 --- a/tests/phpunit/tests/user/multisite.php +++ b/tests/phpunit/tests/user/multisite.php @@ -124,7 +124,7 @@ if ( is_multisite() ) : $blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) ); - $this->assertInternalType( 'int', $blog_id ); + $this->assertIsInt( $blog_id ); $this->assertTrue( is_blog_user( $blog_id ) ); $this->assertTrue( remove_user_from_blog( $user1_id, $blog_id ) ); $this->assertFalse( is_blog_user( $blog_id ) ); @@ -156,7 +156,7 @@ if ( is_multisite() ) : $blog_id = self::factory()->blog->create( array( 'user_id' => get_current_user_id() ) ); - $this->assertInternalType( 'int', $blog_id ); + $this->assertIsInt( $blog_id ); // Current user gets added to new blogs. $this->assertTrue( is_user_member_of_blog( $user1_id, $blog_id ) ); diff --git a/tests/phpunit/tests/widgets.php b/tests/phpunit/tests/widgets.php index e1464a9398..9ea548055a 100644 --- a/tests/phpunit/tests/widgets.php +++ b/tests/phpunit/tests/widgets.php @@ -624,7 +624,7 @@ class Tests_Widgets extends WP_UnitTestCase { $this->assertSame( 1, $option_value['_multiwidget'] ); $this->assertArrayHasKey( 2, $option_value ); $instance = $option_value[2]; - $this->assertInternalType( 'array', $instance ); + $this->assertIsArray( $instance ); $this->assertArrayHasKey( 'content', $instance ); unset( $option_value['_multiwidget'] ); @@ -875,11 +875,11 @@ class Tests_Widgets extends WP_UnitTestCase { $result = retrieve_widgets( true ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { - $this->assertInternalType( 'array', $widgets ); + $this->assertIsArray( $widgets ); } $this->assertContains( 'tag_cloud-1', $sidebars_widgets['sidebar-1'] ); @@ -924,11 +924,11 @@ class Tests_Widgets extends WP_UnitTestCase { $result = retrieve_widgets( true ); // $sidebars_widgets matches registered sidebars. - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { - $this->assertInternalType( 'array', $widgets ); + $this->assertIsArray( $widgets ); } $this->assertContains( 'tag_cloud-1', $sidebars_widgets['sidebar-1'] ); @@ -963,11 +963,11 @@ class Tests_Widgets extends WP_UnitTestCase { $result = retrieve_widgets( true ); $_wp_sidebars_widgets = array(); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { - $this->assertInternalType( 'array', $widgets ); + $this->assertIsArray( $widgets ); } // Current theme doesn't have a fantasy-sidebar. @@ -1005,11 +1005,11 @@ class Tests_Widgets extends WP_UnitTestCase { $result = retrieve_widgets(); $_wp_sidebars_widgets = array(); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { - $this->assertInternalType( 'array', $widgets ); + $this->assertIsArray( $widgets ); } // This sidebar is not registered anymore. @@ -1056,11 +1056,11 @@ class Tests_Widgets extends WP_UnitTestCase { $result = retrieve_widgets( 'customize' ); $_wp_sidebars_widgets = array(); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( $result, $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { - $this->assertInternalType( 'array', $widgets ); + $this->assertIsArray( $widgets ); } $this->assertContains( 'tag_cloud-1', $sidebars_widgets['sidebar-1'] ); @@ -1124,10 +1124,10 @@ class Tests_Widgets extends WP_UnitTestCase { retrieve_widgets(); - $this->assertInternalType( 'array', $sidebars_widgets ); + $this->assertIsArray( $sidebars_widgets ); foreach ( $sidebars_widgets as $widgets ) { - $this->assertInternalType( 'array', $widgets ); + $this->assertIsArray( $widgets ); } // 5 default widgets + 1 orphaned calendar widget = 6. @@ -1157,12 +1157,12 @@ class Tests_Widgets extends WP_UnitTestCase { $filtered_widgets = _wp_remove_unregistered_widgets( $widgets, $allowed_widgets ); - $this->assertInternalType( 'array', $filtered_widgets ); + $this->assertIsArray( $filtered_widgets ); $this->assertArrayHasKey( 'fantasy', $filtered_widgets ); $this->assertEmpty( $filtered_widgets['fantasy'] ); $this->assertArrayHasKey( 'array_version', $filtered_widgets ); $this->assertSame( 3, $filtered_widgets['array_version'] ); - $this->assertInternalType( 'integer', $filtered_widgets['array_version'] ); + $this->assertIsInt( $filtered_widgets['array_version'] ); } /** diff --git a/tests/phpunit/tests/widgets/media-widget.php b/tests/phpunit/tests/widgets/media-widget.php index f91b5e12c1..3877994ea3 100644 --- a/tests/phpunit/tests/widgets/media-widget.php +++ b/tests/phpunit/tests/widgets/media-widget.php @@ -219,7 +219,7 @@ class Test_WP_Widget_Media extends WP_UnitTestCase { $this->filter_instance_schema_args = null; add_filter( 'widget_mocked_instance_schema', array( $this, 'filter_instance_schema' ), 10, 2 ); $schema = $widget->get_instance_schema(); - $this->assertInternalType( 'array', $this->filter_instance_schema_args ); + $this->assertIsArray( $this->filter_instance_schema_args ); $this->assertSame( $widget, $this->filter_instance_schema_args['widget'] ); $this->assertSameSets( array( 'attachment_id', 'title', 'url' ), array_keys( $this->filter_instance_schema_args['schema'] ) ); $this->assertArrayHasKey( 'injected', $schema ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php index 4522b7d943..989f5c2290 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/getPost.php @@ -52,27 +52,27 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['userid'] ); - $this->assertInternalType( 'int', $result['postid'] ); - $this->assertInternalType( 'string', $result['description'] ); - $this->assertInternalType( 'string', $result['title'] ); - $this->assertInternalType( 'string', $result['link'] ); - $this->assertInternalType( 'string', $result['permaLink'] ); - $this->assertInternalType( 'array', $result['categories'] ); - $this->assertInternalType( 'string', $result['mt_excerpt'] ); - $this->assertInternalType( 'string', $result['mt_text_more'] ); - $this->assertInternalType( 'string', $result['wp_more_text'] ); - $this->assertInternalType( 'int', $result['mt_allow_comments'] ); - $this->assertInternalType( 'int', $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->assertInternalType( 'array', $result['custom_fields'] ); - $this->assertInternalType( 'string', $result['wp_post_format'] ); - $this->assertInternalType( 'bool', $result['sticky'] ); + $this->assertIsString( $result['userid'] ); + $this->assertIsInt( $result['postid'] ); + $this->assertIsString( $result['description'] ); + $this->assertIsString( $result['title'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['permaLink'] ); + $this->assertIsArray( $result['categories'] ); + $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->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->assertIsString( $result['wp_post_format'] ); + $this->assertIsBool( $result['sticky'] ); $post_data = get_post( self::$post_id ); @@ -102,7 +102,7 @@ class Tests_XMLRPC_mw_getPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->mw_getPost( array( self::$post_id, 'author', 'author' ) ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'int', $result['wp_post_thumbnail'] ); + $this->assertIsInt( $result['wp_post_thumbnail'] ); $this->assertSame( $attachment_id, $result['wp_post_thumbnail'] ); remove_theme_support( 'post-thumbnails' ); diff --git a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php index e7338a569c..71bc3b92b7 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php +++ b/tests/phpunit/tests/xmlrpc/mw/getRecentPosts.php @@ -58,26 +58,26 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $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->assertInternalType( 'array', $result['categories'] ); - $this->assertInternalType( 'string', $result['mt_excerpt'] ); - $this->assertInternalType( 'string', $result['mt_text_more'] ); - $this->assertInternalType( 'string', $result['wp_more_text'] ); - $this->assertInternalType( 'int', $result['mt_allow_comments'] ); - $this->assertInternalType( 'int', $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->assertInternalType( 'array', $result['custom_fields'] ); - $this->assertInternalType( 'string', $result['wp_post_format'] ); + $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->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->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->assertIsString( $result['wp_post_format'] ); // Check expected values. $this->assertStringMatchesFormat( '%d', $result['userid'] ); @@ -106,7 +106,7 @@ class Tests_XMLRPC_mw_getRecentPosts extends WP_XMLRPC_UnitTestCase { $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/deleteTerm.php b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php index 086bc4ad25..cdbb91ac22 100644 --- a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php @@ -70,6 +70,6 @@ class Tests_XMLRPC_wp_deleteTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_deleteTerm( array( 1, 'editor', 'editor', 'category', self::$term_id ) ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'boolean', $result ); + $this->assertIsBool( $result ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/editPost.php b/tests/phpunit/tests/xmlrpc/wp/editPost.php index 84ca2788c7..4e502f4df5 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/editPost.php @@ -159,7 +159,7 @@ class Tests_XMLRPC_wp_editPost extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPost( array( 1, 'author', 'author', $post_id ) ); $this->assertNotIXRError( $result ); $this->assertArrayHasKey( 'post_thumbnail', $result ); - $this->assertInternalType( 'array', $result['post_thumbnail'] ); + $this->assertIsArray( $result['post_thumbnail'] ); $this->assertEquals( $attachment_id, $result['post_thumbnail']['attachment_id'] ); // Edit the post without supplying a post_thumbnail and check that it didn't change. diff --git a/tests/phpunit/tests/xmlrpc/wp/editTerm.php b/tests/phpunit/tests/xmlrpc/wp/editTerm.php index 27070140af..9754060af7 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/editTerm.php @@ -155,7 +155,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'boolean', $result ); + $this->assertIsBool( $result ); $term = get_term( self::$child_term, 'category' ); $this->assertEquals( '0', $term->parent ); @@ -236,7 +236,7 @@ class Tests_XMLRPC_wp_editTerm extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_editTerm( array( 1, 'editor', 'editor', self::$child_term, $fields ) ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'boolean', $result ); + $this->assertIsBool( $result ); } /** diff --git a/tests/phpunit/tests/xmlrpc/wp/getComment.php b/tests/phpunit/tests/xmlrpc/wp/getComment.php index bf5d01b454..1f9b7cd9f5 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComment.php @@ -54,20 +54,20 @@ class Tests_XMLRPC_wp_getComment extends WP_XMLRPC_UnitTestCase { $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/getComments.php b/tests/phpunit/tests/xmlrpc/wp/getComments.php index 5ec958762f..b3ccdc224b 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getComments.php +++ b/tests/phpunit/tests/xmlrpc/wp/getComments.php @@ -198,7 +198,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertInternalType( 'array', $result2 ); + $this->assertIsArray( $result2 ); $this->assertCount( 1, $result2 ); $result3 = $this->myxmlrpcserver->wp_getComments( @@ -225,7 +225,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertInternalType( 'array', $result4 ); + $this->assertIsArray( $result4 ); $this->assertCount( 1, $result4 ); } @@ -276,7 +276,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { ), ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertCount( 1, $result ); $result2 = $this->myxmlrpcserver->wp_getComments( @@ -291,7 +291,7 @@ class Tests_XMLRPC_wp_getComments extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertInternalType( 'array', $result2 ); + $this->assertIsArray( $result2 ); $this->assertCount( 1, $result2 ); } } diff --git a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php index 26b2ac4aa1..39f31726b9 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php +++ b/tests/phpunit/tests/xmlrpc/wp/getMediaItem.php @@ -50,15 +50,15 @@ class Tests_XMLRPC_wp_getMediaItem extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['attachment_id'] ); - $this->assertInternalType( 'int', $result['parent'] ); - $this->assertInternalType( 'string', $result['title'] ); + $this->assertIsString( $result['attachment_id'] ); + $this->assertIsInt( $result['parent'] ); + $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->assertInternalType( 'array', $result['metadata'] ); + $this->assertIsString( $result['caption'] ); + $this->assertIsString( $result['description'] ); + $this->assertIsString( $result['link'] ); + $this->assertIsString( $result['thumbnail'] ); + $this->assertIsArray( $result['metadata'] ); // Check expected values. $this->assertStringMatchesFormat( '%d', $result['attachment_id'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getOptions.php b/tests/phpunit/tests/xmlrpc/wp/getOptions.php index 6ffdf4503d..08db40606b 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getOptions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getOptions.php @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'subscriber', 'subscriber' ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 'WordPress', $result['software_name']['value'] ); } @@ -23,7 +23,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'administrator' ); $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'administrator', 'administrator', 'default_comment_status' ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( get_option( 'default_comment_status' ), $result['default_comment_status']['value'] ); $this->assertFalse( $result['default_comment_status']['readonly'] ); @@ -37,7 +37,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'subscriber' ); $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'subscriber', 'subscriber' ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); // Read-only options. $this->assertSame( 'WordPress', $result['software_name']['value'] ); @@ -126,7 +126,7 @@ class Tests_XMLRPC_wp_getOptions extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'administrator' ); $result = $this->myxmlrpcserver->wp_getOptions( array( 1, 'administrator', 'administrator' ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); // Read-only options. $this->assertSame( 'WordPress', $result['software_name']['value'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPage.php b/tests/phpunit/tests/xmlrpc/wp/getPage.php index 03b54a58b6..5d9eca3cde 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPage.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPage.php @@ -46,28 +46,28 @@ class Tests_XMLRPC_wp_getPage extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['userid'] ); - $this->assertInternalType( 'int', $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->assertInternalType( 'array', $result['categories'] ); - $this->assertInternalType( 'string', $result['excerpt'] ); - $this->assertInternalType( 'string', $result['text_more'] ); - $this->assertInternalType( 'int', $result['mt_allow_comments'] ); - $this->assertInternalType( 'int', $result['mt_allow_pings'] ); - $this->assertInternalType( 'string', $result['wp_slug'] ); - $this->assertInternalType( 'string', $result['wp_password'] ); - $this->assertInternalType( 'string', $result['wp_author'] ); - $this->assertInternalType( 'int', $result['wp_page_parent_id'] ); - $this->assertInternalType( 'string', $result['wp_page_parent_title'] ); - $this->assertInternalType( 'int', $result['wp_page_order'] ); - $this->assertInternalType( 'string', $result['wp_author_id'] ); - $this->assertInternalType( 'string', $result['wp_author_display_name'] ); - $this->assertInternalType( 'array', $result['custom_fields'] ); - $this->assertInternalType( 'string', $result['wp_page_template'] ); + $this->assertIsString( $result['userid'] ); + $this->assertIsInt( $result['page_id'] ); + $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->assertIsString( $result['excerpt'] ); + $this->assertIsString( $result['text_more'] ); + $this->assertIsInt( $result['mt_allow_comments'] ); + $this->assertIsInt( $result['mt_allow_pings'] ); + $this->assertIsString( $result['wp_slug'] ); + $this->assertIsString( $result['wp_password'] ); + $this->assertIsString( $result['wp_author'] ); + $this->assertIsInt( $result['wp_page_parent_id'] ); + $this->assertIsString( $result['wp_page_parent_title'] ); + $this->assertIsInt( $result['wp_page_order'] ); + $this->assertIsString( $result['wp_author_id'] ); + $this->assertIsString( $result['wp_author_display_name'] ); + $this->assertIsArray( $result['custom_fields'] ); + $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 6752677d97..4a716dd336 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -42,26 +42,26 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $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->assertInternalType( 'bool', $result['sticky'] ); - $this->assertInternalType( 'string', $result['post_format'] ); - $this->assertInternalType( 'array', $result['post_thumbnail'] ); - $this->assertInternalType( 'array', $result['custom_fields'] ); + $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->assertIsString( $result['post_format'] ); + $this->assertIsArray( $result['post_thumbnail'] ); + $this->assertIsArray( $result['custom_fields'] ); // Check expected values. $this->assertStringMatchesFormat( '%d', $result['post_id'] ); @@ -137,11 +137,11 @@ class Tests_XMLRPC_wp_getPost extends WP_XMLRPC_UnitTestCase { $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->assertInternalType( 'int', $result['menu_order'] ); - $this->assertInternalType( 'string', $result['guid'] ); - $this->assertInternalType( 'string', $result['post_mime_type'] ); + $this->assertIsString( $result['post_id'] ); + $this->assertIsString( $result['post_parent'] ); + $this->assertIsInt( $result['menu_order'] ); + $this->assertIsString( $result['guid'] ); + $this->assertIsString( $result['post_mime_type'] ); $this->assertSame( '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 5c0f4ddb19..3d77a48d3e 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostType.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostType.php @@ -59,62 +59,62 @@ class Tests_XMLRPC_wp_getPostType extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $result ); // Check data types. - $this->assertInternalType( 'string', $result['name'] ); - $this->assertInternalType( 'string', $result['label'] ); - $this->assertInternalType( 'bool', $result['hierarchical'] ); - $this->assertInternalType( 'bool', $result['public'] ); - $this->assertInternalType( 'bool', $result['_builtin'] ); - $this->assertInternalType( 'bool', $result['map_meta_cap'] ); - $this->assertInternalType( 'bool', $result['has_archive'] ); - $this->assertInternalType( 'bool', $result['show_ui'] ); - $this->assertInternalType( 'int', $result['menu_position'] ); - $this->assertInternalType( 'string', $result['menu_icon'] ); - $this->assertInternalType( 'array', $result['labels'] ); - $this->assertInternalType( 'array', $result['cap'] ); - $this->assertInternalType( 'array', $result['taxonomies'] ); - $this->assertInternalType( 'array', $result['supports'] ); + $this->assertIsString( $result['name'] ); + $this->assertIsString( $result['label'] ); + $this->assertIsBool( $result['hierarchical'] ); + $this->assertIsBool( $result['public'] ); + $this->assertIsBool( $result['_builtin'] ); + $this->assertIsBool( $result['map_meta_cap'] ); + $this->assertIsBool( $result['has_archive'] ); + $this->assertIsBool( $result['show_ui'] ); + $this->assertIsInt( $result['menu_position'] ); + $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->assertInternalType( 'bool', $value ); + $this->assertIsString( $key ); + $this->assertIsBool( $value ); } // Check expected values. diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php index 3afa962d34..a72cbdcdae 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostTypes.php @@ -15,7 +15,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'subscriber', 'subscriber' ) ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( 0, count( $result ) ); } @@ -24,7 +24,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor' ) ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertGreaterThan( 0, count( $result ) ); } @@ -33,7 +33,7 @@ class Tests_XMLRPC_wp_getPostTypes extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_getPostTypes( array( 1, 'editor', 'editor', array( 'hierarchical' => true ) ) ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); // Verify that page is in the result, and post is not. $result_names = wp_list_pluck( $result, 'name' ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php index c80e55ac9e..f16944a93e 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getRevisions.php +++ b/tests/phpunit/tests/xmlrpc/wp/getRevisions.php @@ -41,7 +41,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { ); // Create the initial revision. $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertCount( 1, $result ); wp_insert_post( @@ -52,7 +52,7 @@ class Tests_XMLRPC_wp_getRevisions extends WP_XMLRPC_UnitTestCase { ); $result = $this->myxmlrpcserver->wp_getRevisions( array( 1, 'editor', 'editor', $post_id ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertCount( 2, $result ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerm.php b/tests/phpunit/tests/xmlrpc/wp/getTerm.php index 13b1698a49..c4e5d1dd3e 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerm.php @@ -79,11 +79,11 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { $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->assertInternalType( 'int', $result['count'] ); + $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. $this->assertStringMatchesFormat( '%d', $result['term_id'] ); @@ -121,7 +121,7 @@ class Tests_XMLRPC_wp_getTerm extends WP_XMLRPC_UnitTestCase { ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'array', $result['custom_fields'] ); + $this->assertIsArray( $result['custom_fields'] ); $term_meta = get_term_meta( self::$term_id, '', true ); $this->assertSame( $term_meta['foo'][0], $result['custom_fields'][0]['value'] ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/getTerms.php b/tests/phpunit/tests/xmlrpc/wp/getTerms.php index 0fb8b0962d..b334235cf5 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getTerms.php +++ b/tests/phpunit/tests/xmlrpc/wp/getTerms.php @@ -48,10 +48,10 @@ class Tests_XMLRPC_wp_getTerms extends WP_XMLRPC_UnitTestCase { $this->assertNotIXRError( $results ); foreach ( $results as $term ) { - $this->assertInternalType( 'int', $term['count'] ); + $this->assertIsInt( $term['count'] ); // Check custom term meta. - $this->assertInternalType( 'array', $term['custom_fields'] ); + $this->assertIsArray( $term['custom_fields'] ); // We expect all other IDs 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 48f2b69494..65ae5c1a96 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUser.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUser.php @@ -69,19 +69,19 @@ class Tests_XMLRPC_wp_getUser extends WP_XMLRPC_UnitTestCase { $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->assertInternalType( 'array', $result['roles'] ); + $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. $this->assertEquals( $user_id, $result['user_id'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsers.php b/tests/phpunit/tests/xmlrpc/wp/getUsers.php index a7dfcf2562..1e9466eb95 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsers.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsers.php @@ -27,19 +27,19 @@ class Tests_XMLRPC_wp_getUsers extends WP_XMLRPC_UnitTestCase { $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->assertInternalType( 'array', $result[0]['roles'] ); + $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'] ); } function test_invalid_role() { diff --git a/tests/phpunit/tests/xmlrpc/wp/newComment.php b/tests/phpunit/tests/xmlrpc/wp/newComment.php index 85e637a540..fb4ebca568 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newComment.php +++ b/tests/phpunit/tests/xmlrpc/wp/newComment.php @@ -208,7 +208,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); $this->assertNotIXRError( $result ); - $this->assertInternalType( 'int', $result ); + $this->assertIsInt( $result ); } /** @@ -290,7 +290,7 @@ class Tests_XMLRPC_wp_newComment extends WP_XMLRPC_UnitTestCase { $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); if ( $expected ) { - $this->assertInternalType( 'int', $result ); + $this->assertIsInt( $result ); return; } diff --git a/tests/phpunit/tests/xmlrpc/wp/newPost.php b/tests/phpunit/tests/xmlrpc/wp/newPost.php index a24a803c6d..8fe16c12de 100644 --- a/tests/phpunit/tests/xmlrpc/wp/newPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/newPost.php @@ -280,11 +280,11 @@ class Tests_XMLRPC_wp_newPost extends WP_XMLRPC_UnitTestCase { $this->make_user_by_role( 'editor' ); $tag1 = wp_create_tag( 'tag1' ); - $this->assertInternalType( 'array', $tag1 ); + $this->assertIsArray( $tag1 ); $tag2 = wp_create_tag( 'tag2' ); - $this->assertInternalType( 'array', $tag2 ); + $this->assertIsArray( $tag2 ); $tag3 = wp_create_tag( 'tag3' ); - $this->assertInternalType( 'array', $tag3 ); + $this->assertIsArray( $tag3 ); $post = array( 'post_title' => 'Test', diff --git a/tests/phpunit/tests/xmlrpc/wp/setOptions.php b/tests/phpunit/tests/xmlrpc/wp/setOptions.php index f99dcc1024..525919bd6d 100644 --- a/tests/phpunit/tests/xmlrpc/wp/setOptions.php +++ b/tests/phpunit/tests/xmlrpc/wp/setOptions.php @@ -26,7 +26,7 @@ class Tests_XMLRPC_wp_setOptions extends WP_XMLRPC_UnitTestCase { ) ); - $this->assertInternalType( 'array', $result ); + $this->assertIsArray( $result ); $this->assertSame( $escaped_string_with_quote, $result['blog_title']['value'] ); $this->assertSame( 'open', $result['default_comment_status']['value'] ); } diff --git a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php index 2f365d7f93..b9ba569a44 100644 --- a/tests/phpunit/tests/xmlrpc/wp/uploadFile.php +++ b/tests/phpunit/tests/xmlrpc/wp/uploadFile.php @@ -27,10 +27,10 @@ class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase { $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'] ); } }