Users: Move the tests added in [35116] and [35618] to a more appropriate place and give them a better name.
See #28435, #29880. git-svn-id: https://develop.svn.wordpress.org/trunk@35732 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
282e87a683
commit
6f310a775d
@ -530,6 +530,20 @@ class Tests_User extends WP_UnitTestCase {
|
||||
$this->assertInstanceOf( 'WP_Error', wp_update_user( array( 'ID' => $user_id ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28435
|
||||
*/
|
||||
function test_wp_update_user_should_not_change_password_when_passed_WP_User_instance() {
|
||||
$testuserid = 1;
|
||||
$user = get_userdata( $testuserid );
|
||||
$pwd_before = $user->user_pass;
|
||||
wp_update_user( $user );
|
||||
|
||||
// Reload the data
|
||||
$pwd_after = get_userdata( $testuserid )->user_pass;
|
||||
$this->assertEquals( $pwd_before, $pwd_after );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28315
|
||||
*/
|
||||
@ -687,6 +701,28 @@ class Tests_User extends WP_UnitTestCase {
|
||||
$this->assertFalse( validate_username( '@#&99sd' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29880
|
||||
*/
|
||||
public function test_wp_insert_user_should_not_wipe_existing_password() {
|
||||
$user_details = array(
|
||||
'user_login' => rand_str(),
|
||||
'user_pass' => 'password',
|
||||
'user_email' => rand_str() . '@example.com',
|
||||
);
|
||||
|
||||
$user_id = wp_insert_user( $user_details );
|
||||
$this->assertEquals( $user_id, email_exists( $user_details['user_email'] ) );
|
||||
|
||||
// Check that providing an empty password doesn't remove a user's password.
|
||||
$user_details['ID'] = $user_id;
|
||||
$user_details['user_pass'] = '';
|
||||
|
||||
$user_id = wp_insert_user( $user_details );
|
||||
$user = WP_User::get_data_by( 'id', $user_id );
|
||||
$this->assertNotEmpty( $user->user_pass );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29696
|
||||
*/
|
||||
@ -1008,39 +1044,4 @@ class Tests_User extends WP_UnitTestCase {
|
||||
wp_new_user_notification( self::$author_id, 'this_is_deprecated' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 28435
|
||||
*/
|
||||
function test_wp_update_user_no_change_pwd() {
|
||||
$testuserid = 1;
|
||||
$user = get_userdata( $testuserid );
|
||||
$pwd_before = $user->user_pass;
|
||||
wp_update_user( $user );
|
||||
|
||||
// Reload the data
|
||||
$pwd_after = get_userdata( $testuserid )->user_pass;
|
||||
$this->assertEquals( $pwd_before, $pwd_after );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29880
|
||||
*/
|
||||
function test_wp_insert_user() {
|
||||
$user_details = array(
|
||||
'user_login' => rand_str(),
|
||||
'user_pass' => 'password',
|
||||
'user_email' => rand_str() . '@example.com',
|
||||
);
|
||||
$id1 = wp_insert_user( $user_details );
|
||||
$this->assertEquals( $id1, email_exists( $user_details['user_email'] ) );
|
||||
|
||||
// Check that providing an empty password doesn't remove a user's password.
|
||||
// See ticket #29880
|
||||
$user_details['ID'] = $id1;
|
||||
$user_details['user_pass'] = '';
|
||||
$id1 = wp_insert_user( $user_details );
|
||||
$user = WP_User::get_data_by( 'id', $id1 );
|
||||
$this->assertNotEmpty( $user->user_pass );
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user