Remove WP < 4.5.0 compatibility code

This commit removes the method Posts::getTerms() as it existed to add a
compatibility layer for sites running WP < 4.5.0 and we don't support
this version anymore. The signature of the WP get_terms() function was
changed in version 4.5.0 and that is why this compatibility layer was
needed.

The integration test class for this method was also removed. The only
place where this method was used, AutomatedLatestContent::getTerms(),
now call WPFunctions->getTerms() directly. A very basic integration test
was added to cover the happy path of AutomatedLatestContent::getTerms().

[MAILPOET-4225]
This commit is contained in:
Rodrigo Primo
2022-04-05 16:23:13 -03:00
committed by Veljko V
parent f85910729e
commit e00d71b781
4 changed files with 22 additions and 78 deletions

View File

@ -2,12 +2,21 @@
namespace MailPoet\Test\API\JSON\v1;
use MailPoet\API\JSON\SuccessResponse;
use MailPoet\API\JSON\v1\AutomatedLatestContent;
class AutomatedLatestContentTest extends \MailPoetTest {
/** @var AutomatedLatestContent */
private $endpoint;
public function _before() {
parent::_before();
$this->endpoint = $this->diContainer->get(AutomatedLatestContent::class);
}
public function testItGetsPostTypes() {
$endpoint = $this->diContainer->get(AutomatedLatestContent::class);
$response = $endpoint->getPostTypes();
$response = $this->endpoint->getPostTypes();
expect($response->data)->notEmpty();
foreach ($response->data as $postType) {
expect($postType)->count(2);
@ -17,8 +26,7 @@ class AutomatedLatestContentTest extends \MailPoetTest {
}
public function testItDoesNotGetPostTypesExludedFromSearch() {
$endpoint = $this->diContainer->get(AutomatedLatestContent::class);
$response = $endpoint ->getPostTypes();
$response = $this->endpoint ->getPostTypes();
// WP's default post type 'revision' is excluded from search
// https://codex.wordpress.org/Post_Types
$revisionPostType = get_post_type_object('revision');
@ -26,4 +34,12 @@ class AutomatedLatestContentTest extends \MailPoetTest {
expect($revisionPostType->exclude_from_search)->true(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
expect(isset($response->data['revision']))->false();
}
public function testItGetTerms() {
$response = $this->endpoint->getTerms();
$this->assertInstanceOf(SuccessResponse::class, $response);
$this->assertCount(1, $response->data);
$this->assertSame('Uncategorized', $response->data['0']->name);
}
}