Make WordPress Core


Ignore:
Timestamp:
04/01/2015 06:22:16 PM (11 years ago)
Author:
wonderboymusic
Message:

When updating the email address for an existing user, make sure the email address is not already in use.

Adds unit tests.

Props rittesh.patel, DrewAPicture.
Fixes #30647.

File:
1 edited

Legend:

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

    r30513 r31963  
    620620
    621621        /**
     622         * @ticket 30647
     623         */
     624        function test_user_update_email_error() {
     625                $id1 = wp_insert_user( array(
     626                        'user_login' => rand_str(),
     627                        'user_pass'  => 'password',
     628                        'user_email' => 'blackburn@battlefield3.com',
     629                ) );
     630                $this->assertEquals( $id1, email_exists( 'blackburn@battlefield3.com' ) );
     631
     632                $id2 = wp_insert_user( array(
     633                        'user_login' => rand_str(),
     634                        'user_pass'  => 'password',
     635                        'user_email' => 'miller@battlefield3.com',
     636                ) );
     637                $this->assertEquals( $id2, email_exists( 'miller@battlefield3.com' ) );
     638
     639                if( ! is_wp_error( $id2 ) ){   
     640                        $return = wp_update_user( array(
     641                                'ID'         => $id2,
     642                                'user_email' => 'david@battlefield3.com',
     643                        ) );
     644                        $this->assertEquals( $id2, email_exists( 'david@battlefield3.com' ) );
     645
     646                        $return = wp_update_user( array(
     647                                'ID'         => $id2,
     648                                'user_email' => 'blackburn@battlefield3.com',
     649                        ) );
     650                        if ( ! defined( 'WP_IMPORTING' ) ) {
     651                                $this->assertWPError( $return );
     652                        }                       
     653                }
     654        }
     655
     656        /**
    622657         * @ticket 29696
    623658         */
Note: See TracChangeset for help on using the changeset viewer.