@@ -14,14 +14,14 @@ public function setUp() {
1414 public function test_register_routes () {
1515 $ routes = $ this ->server ->get_routes ();
1616
17- $ this ->assertArrayHasKey ( '/wp/v2/posts/(?P<post_id>[\d]+)/terms/tag ' , $ routes );
18- $ this ->assertArrayHasKey ( '/wp/v2/posts/(?P<post_id>[\d]+)/terms/tag /(?P<term_id>[\d]+) ' , $ routes );
17+ $ this ->assertArrayHasKey ( '/wp/v2/posts/(?P<post_id>[\d]+)/tags ' , $ routes );
18+ $ this ->assertArrayHasKey ( '/wp/v2/posts/(?P<post_id>[\d]+)/tags /(?P<term_id>[\d]+) ' , $ routes );
1919 }
2020
2121 public function test_get_items () {
2222
2323 wp_set_object_terms ( $ this ->post_id , 'test-tag ' , 'post_tag ' );
24- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag ' , $ this ->post_id ) );
24+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags ' , $ this ->post_id ) );
2525 $ response = $ this ->server ->dispatch ( $ request );
2626
2727 $ this ->assertFalse ( $ response ->is_error () );
@@ -30,38 +30,38 @@ public function test_get_items() {
3030
3131 public function test_get_items_invalid_post () {
3232
33- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag ' , 9999 ) );
33+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags ' , 9999 ) );
3434 $ response = $ this ->server ->dispatch ( $ request );
3535
3636 $ this ->assertErrorResponse ( 'rest_post_invalid_id ' , $ response , 404 );
3737 }
3838
3939 public function test_get_items_invalid_taxonomy () {
4040
41- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/ %s ' , $ this ->public_taxonomy_pages , $ this ->post_id ) );
41+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/%s ' , $ this ->public_taxonomy_pages , $ this ->post_id ) );
4242 $ response = $ this ->server ->dispatch ( $ request );
4343
4444 $ this ->assertErrorResponse ( 'rest_no_route ' , $ response , 404 );
4545 }
4646
4747 public function test_get_items_orderby () {
4848 wp_set_object_terms ( $ this ->post_id , array ( 'Banana ' , 'Carrot ' , 'Apple ' ), 'post_tag ' );
49- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag ' , $ this ->post_id ) );
49+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags ' , $ this ->post_id ) );
5050 $ request ->set_param ( 'orderby ' , 'term_order ' );
5151 $ response = $ this ->server ->dispatch ( $ request );
5252 $ data = $ response ->get_data ();
5353 $ this ->assertEquals ( 'Banana ' , $ data [0 ]['name ' ] );
5454 $ this ->assertEquals ( 'Carrot ' , $ data [1 ]['name ' ] );
5555 $ this ->assertEquals ( 'Apple ' , $ data [2 ]['name ' ] );
56- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag ' , $ this ->post_id ) );
56+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags ' , $ this ->post_id ) );
5757 $ request ->set_param ( 'orderby ' , 'name ' );
5858 $ request ->set_param ( 'order ' , 'asc ' );
5959 $ response = $ this ->server ->dispatch ( $ request );
6060 $ data = $ response ->get_data ();
6161 $ this ->assertEquals ( 'Apple ' , $ data [0 ]['name ' ] );
6262 $ this ->assertEquals ( 'Banana ' , $ data [1 ]['name ' ] );
6363 $ this ->assertEquals ( 'Carrot ' , $ data [2 ]['name ' ] );
64- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag ' , $ this ->post_id ) );
64+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags ' , $ this ->post_id ) );
6565 $ request ->set_param ( 'orderby ' , 'name ' );
6666 $ request ->set_param ( 'order ' , 'desc ' );
6767 $ response = $ this ->server ->dispatch ( $ request );
@@ -75,7 +75,7 @@ public function test_get_item() {
7575 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
7676 wp_set_object_terms ( $ this ->post_id , $ tag ['term_taxonomy_id ' ], 'post_tag ' );
7777
78- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
78+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
7979 $ response = $ this ->server ->dispatch ( $ request );
8080 $ this ->assertFalse ( $ response ->is_error () );
8181
@@ -86,7 +86,7 @@ public function test_get_item_invalid_post() {
8686 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
8787 wp_set_object_terms ( $ this ->post_id , $ tag ['term_taxonomy_id ' ], 'post_tag ' );
8888
89- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , 9999 , $ tag ['term_taxonomy_id ' ] ) );
89+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , 9999 , $ tag ['term_taxonomy_id ' ] ) );
9090 $ response = $ this ->server ->dispatch ( $ request );
9191
9292 $ this ->assertErrorResponse ( 'rest_post_invalid_id ' , $ response , 404 );
@@ -96,21 +96,21 @@ public function test_get_item_post_wrong_post_type() {
9696
9797 $ page = $ this ->factory ->post ->create ( array ( 'post_type ' => 'page ' ) );
9898
99- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag ' , $ page ) );
99+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags ' , $ page ) );
100100 $ response = $ this ->server ->dispatch ( $ request );
101101
102102 $ this ->assertErrorResponse ( 'rest_post_invalid_id ' , $ response , 404 );
103103 }
104104
105105 public function test_get_item_invalid_taxonomy () {
106- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/ invalid_taxonomy/%d ' , $ this ->post_id , 123 ) );
106+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/invalid_taxonomy/%d ' , $ this ->post_id , 123 ) );
107107 $ response = $ this ->server ->dispatch ( $ request );
108108
109109 $ this ->assertErrorResponse ( 'rest_no_route ' , $ response , 404 );
110110 }
111111
112112 public function test_get_item_invalid_taxonomy_term () {
113- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , 9999 ) );
113+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , 9999 ) );
114114 $ response = $ this ->server ->dispatch ( $ request );
115115
116116 $ this ->assertErrorResponse ( 'rest_term_invalid ' , $ response , 404 );
@@ -120,7 +120,7 @@ public function test_get_item_taxonomy_term_wrong_taxonomy() {
120120
121121 $ term = wp_insert_term ( 'some-term ' , $ this ->public_taxonomy_pages );
122122
123- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ term ['term_taxonomy_id ' ] ) );
123+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ term ['term_taxonomy_id ' ] ) );
124124 $ response = $ this ->server ->dispatch ( $ request );
125125
126126 $ this ->assertErrorResponse ( 'rest_term_invalid ' , $ response , 404 );
@@ -130,15 +130,15 @@ public function test_get_item_unassigned_taxonomy_term() {
130130
131131 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
132132
133- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
133+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
134134 $ response = $ this ->server ->dispatch ( $ request );
135135
136136 $ this ->assertErrorResponse ( 'rest_post_not_in_term ' , $ response , 404 );
137137 }
138138
139139 public function test_get_item_term_id_not_added () {
140140 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
141- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
141+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
142142 $ response = $ this ->server ->dispatch ( $ request );
143143
144144 $ this ->assertErrorResponse ( 'rest_post_not_in_term ' , $ response , 404 );
@@ -148,7 +148,7 @@ public function test_create_item() {
148148
149149 wp_set_current_user ( $ this ->admin_id );
150150 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
151- $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
151+ $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
152152 $ response = $ this ->server ->dispatch ( $ request );
153153
154154 $ this ->assertEquals ( 201 , $ response ->get_status () );
@@ -158,7 +158,7 @@ public function test_create_item() {
158158 public function test_create_item_invalid_permission () {
159159
160160 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
161- $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
161+ $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
162162 $ response = $ this ->server ->dispatch ( $ request );
163163
164164 $ this ->assertErrorResponse ( 'rest_forbidden ' , $ response , 403 );
@@ -168,7 +168,7 @@ public function test_create_item_invalid_post() {
168168
169169 wp_set_current_user ( $ this ->admin_id );
170170 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
171- $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , 9999 , $ tag ['term_taxonomy_id ' ] ) );
171+ $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , 9999 , $ tag ['term_taxonomy_id ' ] ) );
172172 $ response = $ this ->server ->dispatch ( $ request );
173173
174174 $ this ->assertErrorResponse ( 'rest_post_invalid_id ' , $ response , 404 );
@@ -178,7 +178,7 @@ public function test_create_item_invalid_taxonomy() {
178178
179179 wp_set_current_user ( $ this ->admin_id );
180180 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
181- $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/terms/ invalid_taxonomy/%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
181+ $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/invalid_taxonomy/%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
182182 $ response = $ this ->server ->dispatch ( $ request );
183183
184184 $ this ->assertErrorResponse ( 'rest_no_route ' , $ response , 404 );
@@ -187,7 +187,7 @@ public function test_create_item_invalid_taxonomy() {
187187 public function test_create_item_invalid_taxonomy_term () {
188188
189189 wp_set_current_user ( $ this ->admin_id );
190- $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , 9999 ) );
190+ $ request = new WP_REST_Request ( 'POST ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , 9999 ) );
191191 $ response = $ this ->server ->dispatch ( $ request );
192192
193193 $ this ->assertErrorResponse ( 'rest_term_invalid ' , $ response , 404 );
@@ -198,7 +198,7 @@ public function test_delete_item() {
198198 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
199199 wp_set_object_terms ( $ this ->post_id , 'test-tag ' , 'post_tag ' );
200200
201- $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
201+ $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
202202 $ request ['force ' ] = true ;
203203 $ response = $ this ->server ->dispatch ( $ request );
204204
@@ -210,7 +210,7 @@ public function test_delete_item_invalid_permission() {
210210 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
211211 wp_set_object_terms ( $ this ->post_id , 'test-tag ' , 'post_tag ' );
212212
213- $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
213+ $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
214214 $ request ['force ' ] = true ;
215215 $ response = $ this ->server ->dispatch ( $ request );
216216
@@ -222,7 +222,7 @@ public function test_delete_item_invalid_taxonomy() {
222222 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
223223 wp_set_object_terms ( $ this ->post_id , 'test-tag ' , 'post_tag ' );
224224
225- $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/terms/ invalid_taxonomy/%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
225+ $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/invalid_taxonomy/%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
226226 $ request ['force ' ] = true ;
227227 $ response = $ this ->server ->dispatch ( $ request );
228228
@@ -234,7 +234,7 @@ public function test_delete_item_invalid_taxonomy_term() {
234234 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
235235 wp_set_object_terms ( $ this ->post_id , 'test-tag ' , 'post_tag ' );
236236
237- $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/terms/ invalid_taxonomy/%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
237+ $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/invalid_taxonomy/%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
238238 $ request ['force ' ] = true ;
239239 $ response = $ this ->server ->dispatch ( $ request );
240240
@@ -246,7 +246,7 @@ public function test_delete_item_invalid_post() {
246246 $ tag = wp_insert_term ( 'test-tag ' , 'post_tag ' );
247247 wp_set_object_terms ( $ this ->post_id , 'test-tag ' , 'post_tag ' );
248248
249- $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , 9999 , $ tag ['term_taxonomy_id ' ] ) );
249+ $ request = new WP_REST_Request ( 'DELETE ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , 9999 , $ tag ['term_taxonomy_id ' ] ) );
250250 $ request ['force ' ] = true ;
251251 $ response = $ this ->server ->dispatch ( $ request );
252252
@@ -262,15 +262,15 @@ public function test_prepare_item() {
262262 wp_set_object_terms ( $ this ->post_id , 'test-tag ' , 'post_tag ' );
263263 $ term = get_term ( $ tag ['term_id ' ], 'post_tag ' );
264264
265- $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/terms/tag /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
265+ $ request = new WP_REST_Request ( 'GET ' , sprintf ( '/wp/v2/posts/%d/tags /%d ' , $ this ->post_id , $ tag ['term_taxonomy_id ' ] ) );
266266 $ response = $ this ->server ->dispatch ( $ request );
267267 $ data = $ response ->get_data ();
268268
269269 $ this ->check_taxonomy_term ( $ term , $ data );
270270 }
271271
272272 public function test_get_item_schema () {
273- $ request = new WP_REST_Request ( 'OPTIONS ' , sprintf ( '/wp/v2/posts/%d/terms/tag ' , $ this ->post_id ) );
273+ $ request = new WP_REST_Request ( 'OPTIONS ' , sprintf ( '/wp/v2/posts/%d/tags ' , $ this ->post_id ) );
274274 $ response = $ this ->server ->dispatch ( $ request );
275275
276276 $ data = $ response ->get_data ();
0 commit comments