Skip to content

Commit

Permalink
Tests: replace assert[Not]InternalType( 'bool', $var ) with `assert…
Browse files Browse the repository at this point in the history
…Is[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
* sebastianbergmann/phpunit#3368
  • Loading branch information
jrfnl committed Aug 16, 2020
1 parent 6243243 commit 790233c
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/tests/customize/widgets.php
Expand Up @@ -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'] );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/rest-api/rest-post-meta-fields.php
Expand Up @@ -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'] );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/rest-api/rest-term-meta-fields.php
Expand Up @@ -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'] );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/mw/getPost.php
Expand Up @@ -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 );

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/wp/deleteTerm.php
Expand Up @@ -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 );
}
}
4 changes: 2 additions & 2 deletions tests/phpunit/tests/xmlrpc/wp/editTerm.php
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/tests/xmlrpc/wp/getPost.php
Expand Up @@ -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'] );
Expand Down
14 changes: 7 additions & 7 deletions tests/phpunit/tests/xmlrpc/wp/getPostType.php
Expand Up @@ -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'] );
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 790233c

Please sign in to comment.