WordPress.org

Make WordPress Core

Changeset 39096


Ignore:
Timestamp:
11/02/2016 09:20:12 PM (5 years ago)
Author:
joehoyle
Message:

REST API: Add en_US to the locales enum.

Props ocean90.
Fixes #38528.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php

    r39092 r39096  
    10701070                    'description' => __( 'Locale for the resource.' ),
    10711071                    'type'        => 'string',
    1072                     'enum'        => get_available_languages(),
     1072                    'enum'        => array_merge( array( 'en_US' ), get_available_languages() ),
    10731073                    'context'     => array( 'edit' ),
    10741074                ),
  • trunk/tests/phpunit/tests/rest-api/rest-users-controller.php

    r39092 r39096  
    837837        $this->assertInstanceOf( 'WP_Error', $response->as_error() );
    838838        $this->assertEquals( 'rest_invalid_param', $response->as_error()->get_error_code() );
     839    }
     840
     841    public function test_update_item_en_US_locale() {
     842        $user_id = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
     843        $this->allow_user_to_manage_multisite();
     844        wp_set_current_user( self::$user );
     845
     846        $request = new WP_REST_Request( 'PUT', '/wp/v2/users/' . $user_id );
     847        $request->set_param( 'locale', 'en_US' );
     848        $response = $this->server->dispatch( $request );
     849        $this->check_add_edit_user_response( $response, true );
     850
     851        $user = get_userdata( $user_id );
     852        $this->assertEquals( 'en_US', $user->locale );
    839853    }
    840854
Note: See TracChangeset for help on using the changeset viewer.