mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-06 05:34:26 +00:00
REST API: Ensure that all properties of get_endpoint_args_for_item_schema are listed.
* Add new var $valid_schema_properties to match rest_validate_value_from_schema() * Unit test to ensure all valid properties exists, and non-valid properties are ignored Fixes: #50301. Props: pentatonicfunk, TimothyBlynJacobs. git-svn-id: https://develop.svn.wordpress.org/trunk@47911 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -247,6 +247,33 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
$this->assertEquals( 'a', $args['somedefault']['default'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 50301
|
||||
*/
|
||||
public function test_get_endpoint_args_for_item_schema_arg_properties() {
|
||||
|
||||
$controller = new WP_REST_Test_Controller();
|
||||
$args = $controller->get_endpoint_args_for_item_schema();
|
||||
|
||||
foreach ( array( 'minLength', 'maxLength', 'pattern' ) as $property ) {
|
||||
$this->assertArrayHasKey( $property, $args['somestring'] );
|
||||
}
|
||||
|
||||
foreach ( array( 'minimum', 'maximum', 'exclusiveMinimum', 'exclusiveMaximum' ) as $property ) {
|
||||
$this->assertArrayHasKey( $property, $args['someinteger'] );
|
||||
}
|
||||
|
||||
$this->assertArrayHasKey( 'items', $args['somearray'] );
|
||||
|
||||
foreach ( array( 'properties', 'additionalProperties' ) as $property ) {
|
||||
$this->assertArrayHasKey( $property, $args['someobject'] );
|
||||
}
|
||||
|
||||
// ignored properties
|
||||
$this->assertArrayNotHasKey( 'ignored_prop', $args['someobject'] );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider data_get_fields_for_response,
|
||||
*/
|
||||
@@ -267,6 +294,8 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
'someenum',
|
||||
'someargoptions',
|
||||
'somedefault',
|
||||
'somearray',
|
||||
'someobject',
|
||||
),
|
||||
$fields
|
||||
);
|
||||
@@ -298,6 +327,8 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
'someenum',
|
||||
'someargoptions',
|
||||
'somedefault',
|
||||
'somearray',
|
||||
'someobject',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user