Skip to content

Commit 9939e36

Browse files
committed
Fix test for expected routes in REST API schema
1 parent bcc6ff9 commit 9939e36

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

tests/phpunit/tests/rest-api/rest-schema-setup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ 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-abilities/v1',
198199
'/wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\-\/]+?)/run',
199200
'/wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\-\/]+)',
200201
'/wp-abilities/v1/abilities',
@@ -208,7 +209,8 @@ private function is_builtin_route( $route ) {
208209
'/' === $route ||
209210
preg_match( '#^/oembed/1\.0(/.+)?$#', $route ) ||
210211
preg_match( '#^/wp/v2(/.+)?$#', $route ) ||
211-
preg_match( '#^/wp-site-health/v1(/.+)?$#', $route )
212+
preg_match( '#^/wp-site-health/v1(/.+)?$#', $route ) ||
213+
preg_match( '#^/wp-abilities/v1(/.+)?$#', $route )
212214
);
213215
}
214216

tests/qunit/fixtures/wp-api-generated.js

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ mockedApiResponse.Schema = {
1919
"oembed/1.0",
2020
"wp/v2",
2121
"wp-site-health/v1",
22-
"wp-block-editor/v1"
22+
"wp-block-editor/v1",
23+
"wp-abilities/v1",
2324
],
2425
"authentication": {
2526
"application-passwords": {
@@ -12392,8 +12393,38 @@ mockedApiResponse.Schema = {
1239212393
}
1239312394
]
1239412395
},
12396+
"/wp-abilities/v1": {
12397+
"namespace": "wp-abilities/v1",
12398+
"methods": [
12399+
"GET"
12400+
],
12401+
"endpoints": [
12402+
{
12403+
"methods": [
12404+
"GET"
12405+
],
12406+
"args": {
12407+
"namespace": {
12408+
"default": "wp-abilities/v1",
12409+
"required": false
12410+
},
12411+
"context": {
12412+
"default": "view",
12413+
"required": false
12414+
}
12415+
}
12416+
}
12417+
],
12418+
"_links": {
12419+
"self": [
12420+
{
12421+
"href": "http://example.org/index.php?rest_route=/wp-abilities/v1"
12422+
}
12423+
]
12424+
}
12425+
},
1239512426
"/wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\\-\\/]+?)/run": {
12396-
"namespace": "wp/v2",
12427+
"namespace": "/wp-abilities/v1",
1239712428
"methods": [
1239812429
"GET",
1239912430
"POST",
@@ -12436,7 +12467,7 @@ mockedApiResponse.Schema = {
1243612467
]
1243712468
},
1243812469
"/wp-abilities/v1/abilities": {
12439-
"namespace": "wp/v2",
12470+
"namespace": "/wp-abilities/v1",
1244012471
"methods": [
1244112472
"GET"
1244212473
],
@@ -12489,7 +12520,7 @@ mockedApiResponse.Schema = {
1248912520
}
1249012521
},
1249112522
"/wp-abilities/v1/abilities/(?P<name>[a-zA-Z0-9\\-\\/]+)": {
12492-
"namespace": "wp/v2",
12523+
"namespace": "/wp-abilities/v1",
1249312524
"methods": [
1249412525
"GET"
1249512526
],

0 commit comments

Comments
 (0)