Make WordPress Core

Changeset 64283


Ignore:
Timestamp:
10/10/2026 02:23:34 PM (4 days ago)
Author:
lancewillett
Message:

Tests: Assert unsupported sidebar REST requests.

Replace empty create and delete test stubs with assertions that unsupported requests return rest_no_route. Verify the sidebar item route accepts GET before checking DELETE.

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/14149

Props shailu25.
See #66073.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-sidebars-controller.php

    r64074 r64283  
    720720
    721721        /**
    722          * The create_item() method does not exist for sidebar.
     722         * Sidebars collection is read-only; create requests should not match a route.
    723723         *
    724          * @doesNotPerformAssertions
     724         * @ticket 66073
    725725         */
    726726        public function test_create_item() {
    727                 // Controller does not implement create_item().
     727                wp_set_current_user( self::$admin_id );
     728
     729                $request  = new WP_REST_Request( 'POST', '/wp/v2/sidebars' );
     730                $response = rest_get_server()->dispatch( $request );
     731
     732                $this->assertErrorResponse( 'rest_no_route', $response, 404 );
    728733        }
    729734
    … …  
    11071112
    11081113        /**
    1109          * The delete_item() method does not exist for sidebar.
     1114         * Sidebars item route is not deletable; delete requests should not match a route.
    11101115         *
    1111          * @doesNotPerformAssertions
     1116         * @ticket 66073
    11121117         */
    11131118        public function test_delete_item() {
    1114                 // Controller does not implement delete_item().
     1119                wp_set_current_user( self::$admin_id );
     1120
     1121                $this->setup_sidebar(
     1122                        'sidebar-1',
     1123                        array(
     1124                                'name' => 'Test sidebar',
     1125                        )
     1126                );
     1127
     1128                $route = '/wp/v2/sidebars/sidebar-1';
     1129
     1130                $response = rest_get_server()->dispatch( new WP_REST_Request( 'GET', $route ) );
     1131                $this->assertSame( 200, $response->get_status() );
     1132
     1133                $request  = new WP_REST_Request( 'DELETE', $route );
     1134                $response = rest_get_server()->dispatch( $request );
     1135
     1136                $this->assertErrorResponse( 'rest_no_route', $response, 404 );
    11151137        }
    11161138
Note: See TracChangeset for help on using the changeset viewer.