- Timestamp:
- 01/28/2025 04:07:07 AM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/wpRestMenuLocationsController.php
r56746 r59718 122 122 123 123 /** 124 * @ticket 54304 125 * @covers ::get_items 126 */ 127 public function test_get_items_filter() { 128 $menus = array( 'primary', 'secondary' ); 129 $this->register_nav_menu_locations( array( 'primary', 'secondary' ) ); 130 add_filter( 'rest_menu_read_access', '__return_true' ); 131 132 $request = new WP_REST_Request( 'GET', '/wp/v2/menu-locations' ); 133 $response = rest_get_server()->dispatch( $request ); 134 $data = $response->get_data(); 135 $data = array_values( $data ); 136 $this->assertCount( 2, $data, 'Number of menu location are not 2' ); 137 138 $names = wp_list_pluck( $data, 'name' ); 139 $descriptions = wp_list_pluck( $data, 'description' ); 140 $this->assertSame( $menus, $names ); 141 $menu_descriptions = array_map( 'ucfirst', $names ); 142 143 $this->assertSame( $menu_descriptions, $descriptions, 'Menu descriptions do not match' ); 144 } 145 146 /** 147 * @ticket 54304 148 * @covers ::get_item 149 */ 150 public function test_get_item_filter() { 151 $menu = 'primary'; 152 $this->register_nav_menu_locations( array( $menu ) ); 153 154 add_filter( 'rest_menu_read_access', '__return_true' ); 155 $request = new WP_REST_Request( 'GET', '/wp/v2/menu-locations/' . $menu ); 156 $response = rest_get_server()->dispatch( $request ); 157 $data = $response->get_data(); 158 159 $this->assertSame( $menu, $data['name'] ); 160 } 161 162 /** 124 163 * @ticket 40878 125 164 * @covers ::get_item
Note: See TracChangeset
for help on using the changeset viewer.