- Timestamp:
- 09/11/2022 11:28:39 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php
r54058 r54131 738 738 ); 739 739 } 740 741 /** 742 * @ticket 56493 743 */ 744 public function test_register_setting_with_custom_additional_properties_value() { 745 wp_set_current_user( self::$administrator ); 746 747 register_setting( 748 'somegroup', 749 'mycustomsetting', 750 array( 751 'type' => 'object', 752 'show_in_rest' => array( 753 'schema' => array( 754 'type' => 'object', 755 'properties' => array( 756 'test1' => array( 757 'type' => 'string', 758 ), 759 ), 760 'additionalProperties' => array( 761 'type' => 'integer', 762 ), 763 ), 764 ), 765 ) 766 ); 767 768 $data = array( 769 'mycustomsetting' => array( 770 'test1' => 'my-string', 771 'test2' => '2', 772 'test3' => 3, 773 ), 774 ); 775 $request = new WP_REST_Request( 'PUT', '/wp/v2/settings' ); 776 $request->add_header( 'content-type', 'application/json' ); 777 $request->set_body( wp_json_encode( $data ) ); 778 779 $response = rest_do_request( $request ); 780 781 $this->assertSame( 200, $response->get_status() ); 782 $this->assertSame( 'my-string', $response->data['mycustomsetting']['test1'] ); 783 $this->assertSame( 2, $response->data['mycustomsetting']['test2'] ); 784 $this->assertSame( 3, $response->data['mycustomsetting']['test3'] ); 785 } 740 786 }
Note: See TracChangeset
for help on using the changeset viewer.