From 2e2aac49c812141fe55291394edfe807db748eb5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 15 Aug 2020 17:20:41 +0200 Subject: [PATCH] Tests: replace `assert[Not]InternalType( 'bool', $var )` with `assertIs[Not]Bool()` The `assertInternalType()` and `assertNotInternalType()` methods were soft deprecated in PHPUnit 7.5, hard deprecated in PHPUnit 8.0 and the functionality was removed in PHPUnit 9.0. The more specific `assertIsArray()`, `assertIsNotArray()`, `assertIsBool()`, `assertIsNotBool()`, `assertIsFloat()`, `assertIsNotFloat()`, `assertIsInt()`, `assertIsNotInt()`, `assertIsNumeric()`, `assertIsNotNumeric()`, `assertIsObject()`, `assertIsNotObject()`, `assertIsResource()`, `assertIsNotResource()`, `assertIsString()`, `assertIsNotString()`, `assertIsScalar()`, `assertIsNotScalar()`, `assertIsCallable()`, `assertIsNotCallable()`, `assertIsIterable()`, `assertIsNotIterable()` methods were introduced as replacements in PHPUnit 7.5. Ref: * https://github.com/sebastianbergmann/phpunit/blob/7.5.20/ChangeLog-7.5.md#750---2018-12-07 * https://github.com/sebastianbergmann/phpunit/issues/3368 --- tests/phpunit/tests/customize/widgets.php | 2 +- .../tests/rest-api/rest-post-meta-fields.php | 2 +- .../tests/rest-api/rest-term-meta-fields.php | 2 +- tests/phpunit/tests/xmlrpc/mw/getPost.php | 2 +- tests/phpunit/tests/xmlrpc/wp/deleteTerm.php | 2 +- tests/phpunit/tests/xmlrpc/wp/editTerm.php | 4 ++-- tests/phpunit/tests/xmlrpc/wp/getPost.php | 2 +- tests/phpunit/tests/xmlrpc/wp/getPostType.php | 14 +++++++------- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/phpunit/tests/customize/widgets.php b/tests/phpunit/tests/customize/widgets.php index b5abb2dab73a..68d8945874bc 100644 --- a/tests/phpunit/tests/customize/widgets.php +++ b/tests/phpunit/tests/customize/widgets.php @@ -436,7 +436,7 @@ function test_wp_widget_form_customize_control_json() { $this->assertArrayHasKey( 'sidebar_id', $params ); $this->assertArrayHasKey( 'width', $params ); $this->assertArrayHasKey( 'height', $params ); - $this->assertInternalType( 'bool', $params['is_wide'] ); + $this->assertIsBool( $params['is_wide'] ); } /** 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 cd73a83e2251..ae2a13ace6db 100644 --- a/tests/phpunit/tests/rest-api/rest-post-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-post-meta-fields.php @@ -403,7 +403,7 @@ public function test_get_value_types() { $this->assertSame( 42.0, $meta['test_number'] ); $this->assertArrayHasKey( 'test_bool', $meta ); - $this->assertInternalType( 'boolean', $meta['test_bool'] ); + $this->assertIsBool( $meta['test_bool'] ); $this->assertSame( true, $meta['test_bool'] ); } 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 9e882e9bd1d3..c99a9092eef1 100644 --- a/tests/phpunit/tests/rest-api/rest-term-meta-fields.php +++ b/tests/phpunit/tests/rest-api/rest-term-meta-fields.php @@ -350,7 +350,7 @@ public function test_get_value_types() { $this->assertSame( 42.0, $meta['test_number'] ); $this->assertArrayHasKey( 'test_bool', $meta ); - $this->assertInternalType( 'boolean', $meta['test_bool'] ); + $this->assertIsBool( $meta['test_bool'] ); $this->assertSame( true, $meta['test_bool'] ); } diff --git a/tests/phpunit/tests/xmlrpc/mw/getPost.php b/tests/phpunit/tests/xmlrpc/mw/getPost.php index 2c9c66039b71..2877b1da7eb2 100644 --- a/tests/phpunit/tests/xmlrpc/mw/getPost.php +++ b/tests/phpunit/tests/xmlrpc/mw/getPost.php @@ -72,7 +72,7 @@ function test_valid_post() { $this->assertInternalType( 'string', $result['post_status'] ); $this->assertIsArray( $result['custom_fields'] ); $this->assertInternalType( 'string', $result['wp_post_format'] ); - $this->assertInternalType( 'bool', $result['sticky'] ); + $this->assertIsBool( $result['sticky'] ); $post_data = get_post( self::$post_id ); diff --git a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php index 40601246c22b..3c0a14f43172 100644 --- a/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/deleteTerm.php @@ -70,6 +70,6 @@ function test_term_deleted() { $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/editTerm.php b/tests/phpunit/tests/xmlrpc/wp/editTerm.php index bea3dde304c1..94b72ab7a3ad 100644 --- a/tests/phpunit/tests/xmlrpc/wp/editTerm.php +++ b/tests/phpunit/tests/xmlrpc/wp/editTerm.php @@ -155,7 +155,7 @@ function test_parent_null() { ); $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 @@ function test_edit_all_fields() { $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/getPost.php b/tests/phpunit/tests/xmlrpc/wp/getPost.php index 06fa1e47418f..c3c0f5d63f04 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPost.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPost.php @@ -58,7 +58,7 @@ function test_valid_post() { $this->assertInternalType( 'string', $result['link'] ); $this->assertInternalType( 'string', $result['comment_status'] ); $this->assertInternalType( 'string', $result['ping_status'] ); - $this->assertInternalType( 'bool', $result['sticky'] ); + $this->assertIsBool( $result['sticky'] ); $this->assertInternalType( 'string', $result['post_format'] ); $this->assertIsArray( $result['post_thumbnail'] ); $this->assertIsArray( $result['custom_fields'] ); diff --git a/tests/phpunit/tests/xmlrpc/wp/getPostType.php b/tests/phpunit/tests/xmlrpc/wp/getPostType.php index 5c126e67a34e..5ba177db88a1 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getPostType.php +++ b/tests/phpunit/tests/xmlrpc/wp/getPostType.php @@ -67,12 +67,12 @@ function test_valid_type() { // 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->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->assertInternalType( 'int', $result['menu_position'] ); $this->assertInternalType( 'string', $result['menu_icon'] ); $this->assertIsArray( $result['labels'] ); @@ -120,7 +120,7 @@ function test_valid_type() { // Check support data types. foreach ( $result['supports'] as $key => $value ) { $this->assertInternalType( 'string', $key ); - $this->assertInternalType( 'bool', $value ); + $this->assertIsBool( $value ); } // Check expected values.