| 918 | /** |
| 919 | * @ticket 57967 |
| 920 | */ |
| 921 | public function test_wp_update_user_should_allow_user_login_with_same_user_email() { |
| 922 | $user_email = str_repeat( 'a', 5 ) . '@example.com'; |
| 923 | |
| 924 | $user_id = wp_insert_user( |
| 925 | array( |
| 926 | 'user_login' => $user_email, |
| 927 | 'user_email' => $user_email, |
| 928 | 'user_pass' => 'whatever', |
| 929 | 'user_nicename' => 'whatever', |
| 930 | ) |
| 931 | ); |
| 932 | |
| 933 | $existing_id = wp_update_user( |
| 934 | array( |
| 935 | 'ID' => $user_id, |
| 936 | 'first_name' => 'Bob', |
| 937 | ) |
| 938 | ); |
| 939 | |
| 940 | $this->assertNotWPError( $existing_id ); |
| 941 | $this->assertSame( $existing_id, $user_id ); |
| 942 | } |
| 943 | |
| 944 | /** |
| 945 | * @ticket 57967 |
| 946 | */ |
| 947 | public function test_wp_update_user_should_reject_user_login_that_matches_existing_user_email() { |
| 948 | $user_email_a = str_repeat( 'a', 5 ) . '@example.com'; |
| 949 | |
| 950 | $user_id_a = wp_insert_user( |
| 951 | array( |
| 952 | 'user_login' => $user_email_a, |
| 953 | 'user_email' => $user_email_a, |
| 954 | 'user_pass' => 'whatever', |
| 955 | 'user_nicename' => 'whatever', |
| 956 | ) |
| 957 | ); |
| 958 | |
| 959 | $user_email_b = str_repeat( 'b', 5 ) . '@example.com'; |
| 960 | |
| 961 | $user_id_b = wp_insert_user( |
| 962 | array( |
| 963 | 'user_login' => $user_email_b, |
| 964 | 'user_email' => $user_email_b, |
| 965 | 'user_pass' => 'whatever', |
| 966 | 'user_nicename' => 'whatever', |
| 967 | ) |
| 968 | ); |
| 969 | |
| 970 | $existing_id_b = wp_update_user( |
| 971 | array( |
| 972 | 'ID' => $user_id_b, |
| 973 | 'user_login' => $user_email_a, |
| 974 | ) |
| 975 | ); |
| 976 | |
| 977 | $this->assertWPError( $existing_id_b ); |
| 978 | $this->assertSame( 'existing_user_email_as_login', $existing_id_b->get_error_code() ); |
| 979 | } |
| 980 | |