- Timestamp:
- 04/29/2022 04:53:55 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-block-directory-controller.php
r52146 r53315 211 211 $this->assertArrayHasKey( 'last_updated', $properties ); 212 212 $this->assertArrayHasKey( 'humanized_updated', $properties ); 213 } 214 215 /** 216 * @ticket 53621 217 */ 218 public function test_get_items_response_conforms_to_schema() { 219 wp_set_current_user( self::$admin_id ); 220 $plugin = $this->get_mock_plugin(); 221 222 // Fetch the block directory schema. 223 $request = new WP_REST_Request( 'OPTIONS', '/wp/v2/block-directory/search' ); 224 $schema = rest_get_server()->dispatch( $request )->get_data()['schema']; 225 226 add_filter( 227 'plugins_api', 228 static function () use ( $plugin ) { 229 return (object) array( 230 'info' => 231 array( 232 'page' => 1, 233 'pages' => 1, 234 'results' => 1, 235 ), 236 'plugins' => array( 237 $plugin, 238 ), 239 ); 240 } 241 ); 242 243 // Fetch a block plugin. 244 $request = new WP_REST_Request( 'GET', '/wp/v2/block-directory/search' ); 245 $request->set_query_params( array( 'term' => 'cache' ) ); 246 247 $result = rest_get_server()->dispatch( $request ); 248 $data = $result->get_data(); 249 250 $valid = rest_validate_value_from_schema( $data[0], $schema ); 251 252 $this->assertNotWPError( $valid ); 213 253 } 214 254
Note: See TracChangeset
for help on using the changeset viewer.