Skip to content

Commit 8448439

Browse files
committed
Tests: Reject unsupported block pattern requests.
Replace empty REST test stubs with assertions that item routes and collection creation return `rest_no_route`. Developed in: #14082 Props shailu25. See #66073. git-svn-id: https://develop.svn.wordpress.org/trunk@64269 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 21020c2 commit 8448439

1 file changed

Lines changed: 41 additions & 8 deletions

File tree

‎tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php‎

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,31 +267,64 @@ public function test_context_param() {
267267
}
268268

269269
/**
270-
* @doesNotPerformAssertions
270+
* Block patterns has no item route.
271+
*
272+
* @ticket 66073
271273
*/
272274
public function test_get_item() {
273-
// Controller does not implement get_item().
275+
wp_set_current_user( self::$admin_id );
276+
277+
$request = new WP_REST_Request( 'GET', static::REQUEST_ROUTE . '/test-one' );
278+
$response = rest_get_server()->dispatch( $request );
279+
280+
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
274281
}
275282

276283
/**
277-
* @doesNotPerformAssertions
284+
* Block patterns is read-only; create requests should not match a route.
285+
*
286+
* @ticket 66073
278287
*/
279288
public function test_create_item() {
280-
// Controller does not implement create_item().
289+
wp_set_current_user( self::$admin_id );
290+
291+
$request = new WP_REST_Request( 'POST', static::REQUEST_ROUTE );
292+
$request->set_param( 'title', 'Example pattern' );
293+
$request->set_param( 'content', '<!-- wp:paragraph --><p>Example</p><!-- /wp:paragraph -->' );
294+
295+
$response = rest_get_server()->dispatch( $request );
296+
297+
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
281298
}
282299

283300
/**
284-
* @doesNotPerformAssertions
301+
* Block patterns has no item route; update requests should not match a route.
302+
*
303+
* @ticket 66073
285304
*/
286305
public function test_update_item() {
287-
// Controller does not implement update_item().
306+
wp_set_current_user( self::$admin_id );
307+
308+
$request = new WP_REST_Request( 'POST', static::REQUEST_ROUTE . '/test-one' );
309+
$request->set_param( 'title', 'Updated' );
310+
311+
$response = rest_get_server()->dispatch( $request );
312+
313+
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
288314
}
289315

290316
/**
291-
* @doesNotPerformAssertions
317+
* Block patterns has no item route; delete requests should not match a route.
318+
*
319+
* @ticket 66073
292320
*/
293321
public function test_delete_item() {
294-
// Controller does not implement delete_item().
322+
wp_set_current_user( self::$admin_id );
323+
324+
$request = new WP_REST_Request( 'DELETE', static::REQUEST_ROUTE . '/test-one' );
325+
$response = rest_get_server()->dispatch( $request );
326+
327+
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
295328
}
296329

297330
/**

0 commit comments

Comments
 (0)