Skip to content

Commit d7640ec

Browse files
committed
Tests: Assert unsupported global styles REST requests.
Replace empty create and delete test stubs with assertions that unsupported requests return `rest_no_route`. Verify the existing global styles item accepts `GET` before checking `DELETE`. Developed in: #14150 Props shailu25. See #66073. git-svn-id: https://develop.svn.wordpress.org/trunk@64289 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0876679 commit d7640ec

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

‎tests/phpunit/tests/rest-api/rest-global-styles-controller.php‎

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,17 @@ public function test_get_item() {
589589
}
590590

591591
/**
592-
* @doesNotPerformAssertions
592+
* Global styles has no collection create route; create requests should not match a route.
593+
*
594+
* @ticket 66073
593595
*/
594596
public function test_create_item() {
595-
// Controller does not implement create_item().
597+
wp_set_current_user( self::$admin_id );
598+
599+
$request = new WP_REST_Request( 'POST', '/wp/v2/global-styles' );
600+
$response = rest_get_server()->dispatch( $request );
601+
602+
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
596603
}
597604

598605
/**
@@ -767,10 +774,22 @@ public function test_update_item_with_custom_block_style_variations() {
767774
}
768775

769776
/**
770-
* @doesNotPerformAssertions
777+
* Global styles item route is not deletable; delete requests should not match a route.
778+
*
779+
* @ticket 66073
771780
*/
772781
public function test_delete_item() {
773-
// Controller does not implement delete_item().
782+
wp_set_current_user( self::$admin_id );
783+
784+
$route = '/wp/v2/global-styles/' . self::$global_styles_id;
785+
786+
$response = rest_get_server()->dispatch( new WP_REST_Request( 'GET', $route ) );
787+
$this->assertSame( 200, $response->get_status() );
788+
789+
$request = new WP_REST_Request( 'DELETE', $route );
790+
$response = rest_get_server()->dispatch( $request );
791+
792+
$this->assertErrorResponse( 'rest_no_route', $response, 404 );
774793
}
775794

776795
/**

0 commit comments

Comments
 (0)