diff --git a/lib/API/JSON/v1/AutomatedLatestContent.php b/lib/API/JSON/v1/AutomatedLatestContent.php index e28be1642e..d57a9370ac 100644 --- a/lib/API/JSON/v1/AutomatedLatestContent.php +++ b/lib/API/JSON/v1/AutomatedLatestContent.php @@ -19,8 +19,14 @@ class AutomatedLatestContent extends APIEndpoint { } function getPostTypes() { + $post_types = array_map(function($post_type) { + return array( + 'name' => $post_type->name, + 'label' => $post_type->label + ); + }, get_post_types(array(), 'objects')); return $this->successResponse( - get_post_types(array(), 'objects') + $post_types ); } @@ -82,4 +88,4 @@ class AutomatedLatestContent extends APIEndpoint { return $this->successResponse($rendered_posts); } -} +} \ No newline at end of file diff --git a/tests/unit/API/JSON/v1/AutomatedLatestContentTest.php b/tests/unit/API/JSON/v1/AutomatedLatestContentTest.php new file mode 100644 index 0000000000..73924f780a --- /dev/null +++ b/tests/unit/API/JSON/v1/AutomatedLatestContentTest.php @@ -0,0 +1,18 @@ +getPostTypes(); + expect($response->data)->notEmpty(); + foreach($response->data as $post_type) { + expect($post_type)->count(2); + expect($post_type['name'])->notEmpty(); + expect($post_type['label'])->notEmpty(); + } + } +}