| 1496 | /** |
| 1497 | * @ticket 44672 |
| 1498 | */ |
| 1499 | public function test_update_item_existing_email_case() { |
| 1500 | wp_set_current_user( self::$editor ); |
| 1501 | |
| 1502 | $user = get_userdata( self::$editor ); |
| 1503 | |
| 1504 | $updated_email_with_case_change = ucwords( $user->user_email, '@' ); |
| 1505 | |
| 1506 | $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) ); |
| 1507 | $request->set_param( 'email', $updated_email_with_case_change ); |
| 1508 | $response = rest_get_server()->dispatch( $request ); |
| 1509 | $data = $response->get_data(); |
| 1510 | |
| 1511 | $this->assertEquals( 200, $response->get_status() ); |
| 1512 | $this->assertEquals( $updated_email_with_case_change, $data['email'] ); |
| 1513 | } |
| 1514 | |
| 1515 | /** |
| 1516 | * @ticket 44672 |
| 1517 | */ |
| 1518 | public function test_update_item_existing_email_case_not_own() { |
| 1519 | wp_set_current_user( self::$editor ); |
| 1520 | |
| 1521 | $user = get_userdata( self::$editor ); |
| 1522 | $subscriber = get_userdata( self::$subscriber ); |
| 1523 | |
| 1524 | $updated_email_with_case_change = ucwords( $subscriber->user_email, '@' ); |
| 1525 | |
| 1526 | $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) ); |
| 1527 | $request->set_param( 'email', $updated_email_with_case_change ); |
| 1528 | $response = rest_get_server()->dispatch( $request ); |
| 1529 | $data = $response->get_data(); |
| 1530 | |
| 1531 | $this->assertEquals( 400, $response->get_status() ); |
| 1532 | } |
| 1533 | |