mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Build/Test Tools: Replace assertInternalType() usage in unit tests.
The `assertInternalType()` and `assertNotInternalType()` methods are deprecated in PHPUnit 8 and removed in PHPUnit 9. While WordPress test suite currently only supports PHPUnit up to 7.5.x, this allows us to switch to newer assertions ahead of adding full support for PHPUnit 8+. These methods introduced in PHPUnit 7.5 should be used as an alternative: * `assertIsArray()` * `assertIsBool()` * `assertIsFloat()` * `assertIsInt()` * `assertIsNumeric()` * `assertIsObject()` * `assertIsResource()` * `assertIsString()` * `assertIsScalar()` * `assertIsCallable()` * `assertIsIterable()` * `assertIsNotArray()` * `assertIsNotBool()` * `assertIsNotFloat()` * `assertIsNotInt()` * `assertIsNotNumeric()` * `assertIsNotObject()` * `assertIsNotResource()` * `assertIsNotString()` * `assertIsNotScalar()` * `assertIsNotCallable()` * `assertIsNotIterable()` As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods are now added to the `WP_UnitTestCase` class for PHPUnit < 7.5. Props pbearne, jrf, dd32, SergeyBiryukov. Fixes #53491. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51331 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user