Make WordPress Core


Ignore:
Timestamp:
11/11/2015 10:30:27 PM (9 years ago)
Author:
wonderboymusic
Message:

Users: in wp_insert_user(), when a password isn't provided and the user exists, ensure that the password isn't wiped out.

Adds unit test.

Props leewillis77.
Fixes #29880.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/user.php

    r35280 r35618  
    10141014        $this->assertEquals( $pwd_before, $pwd_after );
    10151015    }
     1016
     1017    /**
     1018     * @ticket 29880
     1019     */
     1020    function test_wp_insert_user() {
     1021        $user_details = array(
     1022            'user_login' => rand_str(),
     1023            'user_pass' => 'password',
     1024            'user_email' => rand_str() . '@example.com',
     1025        );
     1026        $id1 = wp_insert_user( $user_details );
     1027        $this->assertEquals( $id1, email_exists( $user_details['user_email'] ) );
     1028
     1029        // Check that providing an empty password doesn't remove a user's password.
     1030        // See ticket #29880
     1031        $user_details['ID'] = $id1;
     1032        $user_details['user_pass'] = '';
     1033        $id1 = wp_insert_user( $user_details );
     1034        $user = WP_User::get_data_by( 'id', $id1 );
     1035        $this->assertNotEmpty( $user->user_pass );
     1036    }
     1037
    10161038}
Note: See TracChangeset for help on using the changeset viewer.