Skip to content

Commit 38afbd9

Browse files
committed
Tests: Use assertWPError() in user tests.
Use the dedicated assertion helper for expected `WP_Error` results while retaining the existing error-code and behavior checks. Developed in: #14556 Props shailu25. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64640 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 8147891 commit 38afbd9

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎tests/phpunit/tests/user.php‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ public function test_wp_update_user_on_nonexistent_users() {
844844
}
845845

846846
// If this test fails, it will error out for calling the to_array() method on a non-object.
847-
$this->assertInstanceOf( 'WP_Error', wp_update_user( array( 'ID' => $user_id ) ) );
847+
$this->assertWPError( wp_update_user( array( 'ID' => $user_id ) ) );
848848
}
849849

850850
/**
@@ -1174,7 +1174,7 @@ public function test_illegal_user_logins_single( $user_login ) {
11741174
add_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) );
11751175

11761176
$response = wp_insert_user( $user_data );
1177-
$this->assertInstanceOf( 'WP_Error', $response );
1177+
$this->assertWPError( $response );
11781178
$this->assertSame( 'invalid_username', $response->get_error_code() );
11791179

11801180
remove_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) );
@@ -1194,7 +1194,7 @@ public function test_illegal_user_logins_single_wp_create_user( $user_login ) {
11941194
add_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) );
11951195

11961196
$response = register_new_user( $user_login, $user_email );
1197-
$this->assertInstanceOf( 'WP_Error', $response );
1197+
$this->assertWPError( $response );
11981198
$this->assertSame( 'invalid_username', $response->get_error_code() );
11991199

12001200
remove_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) );
@@ -1217,13 +1217,13 @@ public function test_illegal_user_logins_multisite() {
12171217
add_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) );
12181218

12191219
$response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] );
1220-
$this->assertInstanceOf( 'WP_Error', $response['errors'] );
1220+
$this->assertWPError( $response['errors'] );
12211221
$this->assertSame( 'user_name', $response['errors']->get_error_code() );
12221222

12231223
remove_filter( 'illegal_user_logins', array( $this, 'illegal_user_logins' ) );
12241224

12251225
$response = wpmu_validate_user_signup( $user_data['user_login'], $user_data['user_email'] );
1226-
$this->assertInstanceOf( 'WP_Error', $response['errors'] );
1226+
$this->assertWPError( $response['errors'] );
12271227
$this->assertCount( 0, $response['errors']->get_error_codes() );
12281228
}
12291229

@@ -2191,7 +2191,7 @@ public function test_edit_user_blank_password() {
21912191
// Check new user with missing password.
21922192
$response = edit_user();
21932193

2194-
$this->assertInstanceOf( 'WP_Error', $response );
2194+
$this->assertWPError( $response );
21952195
$this->assertSame( 'pass', $response->get_error_code() );
21962196

21972197
// Check new user with password set.
@@ -2234,7 +2234,7 @@ public function test_edit_user_blank_password() {
22342234

22352235
$response = edit_user( $user_id );
22362236

2237-
$this->assertInstanceOf( 'WP_Error', $response );
2237+
$this->assertWPError( $response );
22382238
$this->assertSame( 'pass', $response->get_error_code() );
22392239
$this->assertSame( 'nickname_updated', $user->nickname );
22402240

0 commit comments

Comments
 (0)