Skip to content

Commit

Permalink
External Media: Add API unit tests (#15988)
Browse files Browse the repository at this point in the history
* [not verified] Add External media endpoint

* [not verified] Add unit tests

* [not verified] Add class coverage info

* Simplify schema

* Fix image copy test

* Use local image

* Remove duplicate file ending

Props @frontdevde.
  • Loading branch information
obenland committed Jun 24, 2020
1 parent 81f731c commit 6a92442
Show file tree
Hide file tree
Showing 2 changed files with 362 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,32 @@ class WPCOM_REST_API_V2_Endpoint_External_Media extends WP_REST_Controller {
* @var array
*/
public $media_schema = array(
'items' => array(
'type' => 'object',
'required' => true,
'properties' => array(
'caption' => array(
'type' => 'string',
),
'guid' => array(
'items' => array(
'caption' => array(
'type' => 'string',
),
'name' => array(
'type' => 'string',
),
'title' => array(
'type' => 'string',
),
'url' => array(
'format' => 'uri',
'type' => 'string',
),
'type' => 'object',
'required' => true,
'properties' => array(
'caption' => array(
'type' => 'string',
),
'guid' => array(
'items' => array(
'caption' => array(
'type' => 'string',
),
'name' => array(
'type' => 'string',
),
'title' => array(
'type' => 'string',
),
'url' => array(
'format' => 'uri',
'type' => 'string',
),
'type' => 'array',
),
'title' => array(
'type' => 'string',
),
'type' => 'array',
),
'title' => array(
'type' => 'string',
),
),
);
Expand Down Expand Up @@ -120,7 +118,7 @@ public function register_routes() {
'args' => array(
'media' => array(
'description' => __( 'Media data to copy.', 'jetpack' ),
'items' => array_values( $this->media_schema ),
'items' => $this->media_schema,
'required' => true,
'type' => 'array',
'sanitize_callback' => array( $this, 'sanitize_media' ),
Expand Down
Loading

0 comments on commit 6a92442

Please sign in to comment.