Changeset 47328
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
r47122 r47328 345 345 $schema = $this->get_item_schema(); 346 346 347 foreach ( $schema['properties'] as &$property ) { 348 unset( $property['arg_options'] ); 347 if ( ! empty( $schema['properties'] ) ) { 348 foreach ( $schema['properties'] as &$property ) { 349 unset( $property['arg_options'] ); 350 } 349 351 } 350 352 -
trunk/tests/phpunit/includes/bootstrap.php
r47198 r47328 155 155 require __DIR__ . '/spy-rest-server.php'; 156 156 require __DIR__ . '/class-wp-rest-test-search-handler.php'; 157 require __DIR__ . '/class-wp-rest-test-configurable-controller.php'; 157 158 require __DIR__ . '/class-wp-fake-block-type.php'; 158 159 -
trunk/tests/phpunit/tests/rest-api/rest-controller.php
r46586 r47328 344 344 } 345 345 346 /** 347 * @ticket 48785 348 */ 349 public function test_get_public_item_schema_with_properties() { 350 $schema = ( new WP_REST_Test_Controller() )->get_public_item_schema(); 351 352 // Double-check that the public item schema set in WP_REST_Test_Controller still has properties. 353 $this->assertArrayHasKey( 'properties', $schema ); 354 355 // But arg_options should be removed. 356 $this->assertArrayNotHasKey( 'arg_options', $schema['properties']['someargoptions'] ); 357 } 358 359 /** 360 * @ticket 48785 361 */ 362 public function test_get_public_item_schema_no_properties() { 363 $controller = new WP_REST_Test_Configurable_Controller( 364 array( 365 '$schema' => 'http://json-schema.org/draft-04/schema#', 366 'title' => 'foo', 367 'type' => 'string', 368 'description' => 'This is my magical endpoint that just returns a string.', 369 ) 370 ); 371 372 // Initial check that the test class is working as expected. 373 $this->assertArrayNotHasKey( 'properties', $controller->get_public_item_schema() ); 374 375 // Test that the schema lacking 'properties' is returned as expected. 376 $this->assertEqualSetsWithIndex( $controller->get_public_item_schema(), $controller->get_test_schema() ); 377 } 378 346 379 public function test_add_additional_fields_to_object_respects_fields_param() { 347 380 $controller = new WP_REST_Test_Controller();
Note: See TracChangeset
for help on using the changeset viewer.