WordPress.org

Make WordPress Core

Changeset 35732


Ignore:
Timestamp:
11/23/2015 06:39:20 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Users: Move the tests added in [35116] and [35618] to a more appropriate place and give them a better name.

See #28435, #29880.

File:
1 edited

Legend:

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

    r35631 r35732  
    532532
    533533    /**
     534     * @ticket 28435
     535     */
     536    function test_wp_update_user_should_not_change_password_when_passed_WP_User_instance() {
     537        $testuserid = 1;
     538        $user = get_userdata( $testuserid );
     539        $pwd_before = $user->user_pass;
     540        wp_update_user( $user );
     541
     542        // Reload the data
     543        $pwd_after = get_userdata( $testuserid )->user_pass;
     544        $this->assertEquals( $pwd_before, $pwd_after );
     545    }
     546
     547    /**
    534548     * @ticket 28315
    535549     */
     
    686700    public function test_validate_username_invalid() {
    687701        $this->assertFalse( validate_username( '@#&99sd' ) );
     702    }
     703
     704    /**
     705     * @ticket 29880
     706     */
     707    public function test_wp_insert_user_should_not_wipe_existing_password() {
     708        $user_details = array(
     709            'user_login' => rand_str(),
     710            'user_pass' => 'password',
     711            'user_email' => rand_str() . '@example.com',
     712        );
     713
     714        $user_id = wp_insert_user( $user_details );
     715        $this->assertEquals( $user_id, email_exists( $user_details['user_email'] ) );
     716
     717        // Check that providing an empty password doesn't remove a user's password.
     718        $user_details['ID'] = $user_id;
     719        $user_details['user_pass'] = '';
     720
     721        $user_id = wp_insert_user( $user_details );
     722        $user = WP_User::get_data_by( 'id', $user_id );
     723        $this->assertNotEmpty( $user->user_pass );
    688724    }
    689725
     
    10091045    }
    10101046
    1011     /**
    1012      * @ticket 28435
    1013      */
    1014     function test_wp_update_user_no_change_pwd() {
    1015         $testuserid = 1;
    1016         $user = get_userdata( $testuserid );
    1017         $pwd_before = $user->user_pass;
    1018         wp_update_user( $user );
    1019 
    1020         // Reload the data
    1021         $pwd_after = get_userdata( $testuserid )->user_pass;
    1022         $this->assertEquals( $pwd_before, $pwd_after );
    1023     }
    1024 
    1025     /**
    1026      * @ticket 29880
    1027      */
    1028     function test_wp_insert_user() {
    1029         $user_details = array(
    1030             'user_login' => rand_str(),
    1031             'user_pass' => 'password',
    1032             'user_email' => rand_str() . '@example.com',
    1033         );
    1034         $id1 = wp_insert_user( $user_details );
    1035         $this->assertEquals( $id1, email_exists( $user_details['user_email'] ) );
    1036 
    1037         // Check that providing an empty password doesn't remove a user's password.
    1038         // See ticket #29880
    1039         $user_details['ID'] = $id1;
    1040         $user_details['user_pass'] = '';
    1041         $id1 = wp_insert_user( $user_details );
    1042         $user = WP_User::get_data_by( 'id', $id1 );
    1043         $this->assertNotEmpty( $user->user_pass );
    1044     }
    1045 
    10461047}
Note: See TracChangeset for help on using the changeset viewer.