Changeset 53315
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php
r52582 r53315 240 240 'rating' => array( 241 241 'description' => __( 'The star rating of the block.' ), 242 'type' => ' integer',242 'type' => 'number', 243 243 'context' => array( 'view' ), 244 244 ), … … 250 250 'active_installs' => array( 251 251 'description' => __( 'The number sites that have activated this block.' ), 252 'type' => ' string',252 'type' => 'integer', 253 253 'context' => array( 'view' ), 254 254 ), 255 255 'author_block_rating' => array( 256 256 'description' => __( 'The average rating of blocks published by the same author.' ), 257 'type' => ' integer',257 'type' => 'number', 258 258 'context' => array( 'view' ), 259 259 ), -
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.