mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-09 15:14:37 +00:00
REST API: Support the uuid JSON Schema format.
This accepts a uuid of any version. A future commit could add support for restricting uuids to a specific version. Props johnwatkins0. Fixes #50053. git-svn-id: https://develop.svn.wordpress.org/trunk@47753 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -43,6 +43,10 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
'type' => 'string',
|
||||
'format' => 'email',
|
||||
),
|
||||
'someuuid' => array(
|
||||
'type' => 'string',
|
||||
'format' => 'uuid',
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
@@ -204,6 +208,20 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 50053
|
||||
*/
|
||||
public function test_validate_schema_format_uuid() {
|
||||
$this->assertTrue(
|
||||
rest_validate_request_arg( '123e4567-e89b-12d3-a456-426655440000', $this->request, 'someuuid' )
|
||||
);
|
||||
|
||||
$this->assertErrorResponse(
|
||||
'rest_invalid_uuid',
|
||||
rest_validate_request_arg( '123e4567-e89b-12d3-a456-426655440000X', $this->request, 'someuuid' )
|
||||
);
|
||||
}
|
||||
|
||||
public function test_get_endpoint_args_for_item_schema_description() {
|
||||
$controller = new WP_REST_Test_Controller();
|
||||
$args = $controller->get_endpoint_args_for_item_schema();
|
||||
@@ -245,6 +263,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
'somedate',
|
||||
'someemail',
|
||||
'somehex',
|
||||
'someuuid',
|
||||
'someenum',
|
||||
'someargoptions',
|
||||
'somedefault',
|
||||
@@ -275,6 +294,7 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
'somedate',
|
||||
'someemail',
|
||||
'somehex',
|
||||
'someuuid',
|
||||
'someenum',
|
||||
'someargoptions',
|
||||
'somedefault',
|
||||
|
||||
Reference in New Issue
Block a user