mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
REST API: Sort widget types by their id.
Fixes #53303. Props spacedmonkey. git-svn-id: https://develop.svn.wordpress.org/trunk@51882 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f660632c9c
commit
6194de49dc
@ -237,6 +237,8 @@ class WP_REST_Widget_Types_Controller extends WP_REST_Controller {
|
||||
$widgets[ $widget['id'] ] = $widget;
|
||||
}
|
||||
|
||||
ksort( $widgets );
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
|
||||
@ -125,6 +125,22 @@ class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 53303
|
||||
*/
|
||||
public function test_get_items_ordering() {
|
||||
wp_set_current_user( self::$admin_id );
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/widget-types' );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
$this->assertGreaterThan( 1, count( $data ) );
|
||||
$ids = wp_list_pluck( $data, 'id' );
|
||||
$sorted = $ids;
|
||||
sort( $sorted );
|
||||
|
||||
$this->assertSame( $sorted, $ids );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 53305
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user