Merge pull request #1084 from mailpoet/editor_get_post_type_optimization
Removes unused properties from the object used to display post types in editor [MAILPOET-1086]
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
18
tests/unit/API/JSON/v1/AutomatedLatestContentTest.php
Normal file
18
tests/unit/API/JSON/v1/AutomatedLatestContentTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Test\API\JSON\v1;
|
||||
|
||||
use MailPoet\API\JSON\v1\AutomatedLatestContent;
|
||||
|
||||
class AutomatedLatestContentTest extends \MailPoetTest {
|
||||
function testItGetsPostTypes() {
|
||||
$router = new AutomatedLatestContent();
|
||||
$response = $router->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();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user