File tree Expand file tree Collapse file tree 4 files changed +115
-10
lines changed
Expand file tree Collapse file tree 4 files changed +115
-10
lines changed Original file line number Diff line number Diff line change @@ -195,6 +195,9 @@ public function test_expected_routes_in_schema() {
195195 '/wp/v2/font-families/(?P<font_family_id>[\d]+)/font-faces ' ,
196196 '/wp/v2/font-families/(?P<font_family_id>[\d]+)/font-faces/(?P<id>[\d]+) ' ,
197197 '/wp/v2/font-families/(?P<id>[\d]+) ' ,
198+ '/wp/v2/abilities/(?P<name>[a-zA-Z0-9\-\/]+?)/run ' ,
199+ '/wp/v2/abilities/(?P<name>[a-zA-Z0-9\-\/]+) ' ,
200+ '/wp/v2/abilities '
198201 );
199202
200203 $ this ->assertSameSets ( $ expected_routes , $ routes );
Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ public function set_up(): void {
4343
4444 // Set up REST server
4545 global $ wp_rest_server ;
46- $ this ->server = $ wp_rest_server = new WP_REST_Server ();
46+ $ wp_rest_server = new WP_REST_Server ();
47+ $ this ->server = $ wp_rest_server ;
48+
4749 do_action ( 'rest_api_init ' );
4850
4951 // Initialize abilities API
@@ -107,7 +109,7 @@ private function register_test_abilities(): void {
107109 case 'multiply ' :
108110 return $ input ['a ' ] * $ input ['b ' ];
109111 case 'divide ' :
110- return $ input ['b ' ] !== 0 ? $ input ['a ' ] / $ input ['b ' ] : null ;
112+ return 0 !== $ input ['b ' ] ? $ input ['a ' ] / $ input ['b ' ] : null ;
111113 default :
112114 return null ;
113115 }
Original file line number Diff line number Diff line change @@ -54,7 +54,9 @@ public function set_up(): void {
5454 parent ::set_up ();
5555
5656 global $ wp_rest_server ;
57- $ this ->server = $ wp_rest_server = new WP_REST_Server ();
57+ $ wp_rest_server = new WP_REST_Server ();
58+ $ this ->server = $ wp_rest_server ;
59+
5860 do_action ( 'rest_api_init ' );
5961
6062 do_action ( 'abilities_api_init ' );
Original file line number Diff line number Diff line change @@ -21,13 +21,7 @@ mockedApiResponse.Schema = {
2121 "wp-site-health/v1",
2222 "wp-block-editor/v1"
2323 ],
24- "authentication": {
25- "application-passwords": {
26- "endpoints": {
27- "authorization": "http://example.org/wp-admin/authorize-application.php"
28- }
29- }
30- },
24+ "authentication": [],
3125 "routes": {
3226 "/": {
3327 "namespace": "",
@@ -12265,6 +12259,110 @@ mockedApiResponse.Schema = {
1226512259 }
1226612260 }
1226712261 ]
12262+ },
12263+ "/wp/v2/abilities/(?P<name>[a-zA-Z0-9\\-\\/]+?)/run": {
12264+ "namespace": "wp/v2",
12265+ "methods": [
12266+ "GET",
12267+ "POST",
12268+ "PUT",
12269+ "PATCH",
12270+ "DELETE"
12271+ ],
12272+ "endpoints": [
12273+ {
12274+ "methods": [
12275+ "GET",
12276+ "POST",
12277+ "PUT",
12278+ "PATCH",
12279+ "DELETE"
12280+ ],
12281+ "args": {
12282+ "name": {
12283+ "description": "Unique identifier for the ability.",
12284+ "type": "string",
12285+ "pattern": "^[a-zA-Z0-9\\-\\/]+$",
12286+ "required": false
12287+ },
12288+ "input": {
12289+ "description": "Input parameters for the ability execution.",
12290+ "type": "object",
12291+ "default": [],
12292+ "required": false
12293+ }
12294+ }
12295+ }
12296+ ]
12297+ },
12298+ "/wp/v2/abilities": {
12299+ "namespace": "wp/v2",
12300+ "methods": [
12301+ "GET"
12302+ ],
12303+ "endpoints": [
12304+ {
12305+ "methods": [
12306+ "GET"
12307+ ],
12308+ "args": {
12309+ "context": {
12310+ "description": "Scope under which the request is made; determines fields present in response.",
12311+ "type": "string",
12312+ "enum": [
12313+ "view",
12314+ "embed",
12315+ "edit"
12316+ ],
12317+ "default": "view",
12318+ "required": false
12319+ },
12320+ "page": {
12321+ "description": "Current page of the collection.",
12322+ "type": "integer",
12323+ "default": 1,
12324+ "minimum": 1,
12325+ "required": false
12326+ },
12327+ "per_page": {
12328+ "description": "Maximum number of items to be returned in result set.",
12329+ "type": "integer",
12330+ "default": 50,
12331+ "minimum": 1,
12332+ "maximum": 100,
12333+ "required": false
12334+ }
12335+ }
12336+ }
12337+ ],
12338+ "_links": {
12339+ "self": [
12340+ {
12341+ "href": "http://example.org/index.php?rest_route=/wp/v2/abilities"
12342+ }
12343+ ]
12344+ }
12345+ },
12346+ "/wp/v2/abilities/(?P<name>[a-zA-Z0-9\\-\\/]+)": {
12347+ "namespace": "wp/v2",
12348+ "methods": [
12349+ "GET"
12350+ ],
12351+ "endpoints": [
12352+ {
12353+ "methods": [
12354+ "GET"
12355+ ],
12356+ "args": {
12357+ "name": {
12358+ "description": "Unique identifier for the ability.",
12359+ "type": "string",
12360+ "pattern": "^[a-zA-Z0-9\\-\\/]+$",
12361+ "required": false
12362+ }
12363+ }
12364+ }
12365+ ]
1226812366 }
1226912367 },
1227012368 "site_logo": 0,
You can’t perform that action at this time.
0 commit comments