mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 01:24:27 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31963 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -618,6 +618,41 @@ class Tests_User extends WP_UnitTestCase {
|
||||
$this->assertNotContains( 'key', $metas );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 30647
|
||||
*/
|
||||
function test_user_update_email_error() {
|
||||
$id1 = wp_insert_user( array(
|
||||
'user_login' => rand_str(),
|
||||
'user_pass' => 'password',
|
||||
'user_email' => 'blackburn@battlefield3.com',
|
||||
) );
|
||||
$this->assertEquals( $id1, email_exists( 'blackburn@battlefield3.com' ) );
|
||||
|
||||
$id2 = wp_insert_user( array(
|
||||
'user_login' => rand_str(),
|
||||
'user_pass' => 'password',
|
||||
'user_email' => 'miller@battlefield3.com',
|
||||
) );
|
||||
$this->assertEquals( $id2, email_exists( 'miller@battlefield3.com' ) );
|
||||
|
||||
if( ! is_wp_error( $id2 ) ){
|
||||
$return = wp_update_user( array(
|
||||
'ID' => $id2,
|
||||
'user_email' => 'david@battlefield3.com',
|
||||
) );
|
||||
$this->assertEquals( $id2, email_exists( 'david@battlefield3.com' ) );
|
||||
|
||||
$return = wp_update_user( array(
|
||||
'ID' => $id2,
|
||||
'user_email' => 'blackburn@battlefield3.com',
|
||||
) );
|
||||
if ( ! defined( 'WP_IMPORTING' ) ) {
|
||||
$this->assertWPError( $return );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29696
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user