Ticket #44672: 44672.diff
File 44672.diff, 1.9 KB (added by , 6 years ago) |
---|
-
src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
624 624 return new WP_Error( 'rest_user_invalid_id', __( 'Invalid user ID.' ), array( 'status' => 404 ) ); 625 625 } 626 626 627 if ( email_exists( $request['email'] ) && $request['email'] !== $user->user_email) {627 if ( email_exists( $request['email'] ) && strtolower( $request['email'] ) !== strtolower( $user->user_email ) ) { 628 628 return new WP_Error( 'rest_user_invalid_email', __( 'Invalid email address.' ), array( 'status' => 400 ) ); 629 629 } 630 630 -
tests/phpunit/tests/rest-api/rest-users-controller.php
1480 1480 $this->assertEquals( 'rest_user_invalid_email', $response->as_error()->get_error_code() ); 1481 1481 } 1482 1482 1483 /** 1484 * @ticket 44672 1485 */ 1486 public function test_update_item_existing_email_case() { 1487 wp_set_current_user( self::$editor ); 1488 1489 $user = get_userdata( self::$editor ); 1490 $updated_email_with_case_change = ucwords( $user->user_email, '@' ); 1491 1492 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) ); 1493 $request->set_param( 'email', $updated_email_with_case_change ); 1494 $response = rest_get_server()->dispatch( $request ); 1495 $data = $response->get_data(); 1496 1497 $this->assertEquals( 200, $response->get_status() ); 1498 $this->assertEquals( $updated_email_with_case_change, $data['email'] ); 1499 } 1500 1483 1501 public function test_update_item_invalid_locale() { 1484 1502 $user1 = $this->factory->user->create( 1485 1503 array(