From d0ea442300947e418577a53e68460261bd6fdcd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Fri, 7 Jan 2022 12:20:22 +0100 Subject: [PATCH] Fix integration tests compatibility [MAILPOET-4001] --- tests/integration/API/JSON/APITest.php | 3 ++- tests/integration/API/MP/APITest.php | 2 +- tests/integration/Config/InstallerTest.php | 2 ++ tests/integration/Config/RendererTest.php | 1 + tests/integration/Config/UpdaterTest.php | 4 ++++ .../integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php | 1 + .../Cron/Workers/SendingQueue/SendingQueueTest.php | 2 +- .../Cron/Workers/StatsNotifications/AutomatedEmailsTest.php | 4 ++-- tests/integration/Mailer/Methods/AmazonSESTest.php | 1 + tests/integration/Mailer/Methods/MailPoetAPITest.php | 2 +- tests/integration/Mailer/Methods/PHPMailTest.php | 1 + tests/integration/Mailer/Methods/SMTPTest.php | 1 + tests/integration/Mailer/Methods/SendGridTest.php | 1 + tests/integration/Services/BridgeTest.php | 2 +- tests/integration/_bootstrap.php | 4 ++-- 15 files changed, 22 insertions(+), 9 deletions(-) diff --git a/tests/integration/API/JSON/APITest.php b/tests/integration/API/JSON/APITest.php index 72fc4e050f..a04c4e9e52 100644 --- a/tests/integration/API/JSON/APITest.php +++ b/tests/integration/API/JSON/APITest.php @@ -25,6 +25,7 @@ require_once('APITestNamespacedEndpointStubV1.php'); require_once('APITestNamespacedEndpointStubV2.php'); class APITest extends \MailPoetTest { + /** @var JSONAPI */ public $api; public $wpUserId; /** @var Container */ @@ -54,7 +55,7 @@ class APITest extends \MailPoetTest { $this->container->compile(); $this->errorHandler = $this->container->get(ErrorHandler::class); $this->settings = $this->container->get(SettingsController::class); - $this->api = new \MailPoet\API\JSON\API( + $this->api = new JSONAPI( $this->container, $this->container->get(AccessControl::class), $this->errorHandler, diff --git a/tests/integration/API/MP/APITest.php b/tests/integration/API/MP/APITest.php index 38bf432726..578a77a47e 100644 --- a/tests/integration/API/MP/APITest.php +++ b/tests/integration/API/MP/APITest.php @@ -61,7 +61,7 @@ class APITest extends \MailPoetTest { ); } - private function getApi($subscriberActions = null) { + private function getApi($subscriberActions = null): API { if (!$subscriberActions) { $subscriberActions = $this->getSubscribers(); } diff --git a/tests/integration/Config/InstallerTest.php b/tests/integration/Config/InstallerTest.php index 1cd07c552d..a861d9043f 100644 --- a/tests/integration/Config/InstallerTest.php +++ b/tests/integration/Config/InstallerTest.php @@ -9,7 +9,9 @@ use MailPoet\Config\Installer; use MailPoet\WP\Functions as WPFunctions; class InstallerTest extends \MailPoetTest { + /** @var Installer */ public $installer; + /** @var string */ public $slug; public function _before() { diff --git a/tests/integration/Config/RendererTest.php b/tests/integration/Config/RendererTest.php index 3d6ced7fd1..0bfca841e5 100644 --- a/tests/integration/Config/RendererTest.php +++ b/tests/integration/Config/RendererTest.php @@ -9,6 +9,7 @@ use MailPoet\Config\Renderer; use MailPoetVendor\Twig\Environment as TwigEnvironment; class RendererTest extends \MailPoetTest { + /** @var Renderer */ public $renderer; public function _before() { diff --git a/tests/integration/Config/UpdaterTest.php b/tests/integration/Config/UpdaterTest.php index 519196e7e6..a59cea36d8 100644 --- a/tests/integration/Config/UpdaterTest.php +++ b/tests/integration/Config/UpdaterTest.php @@ -7,9 +7,13 @@ use Codeception\Stub\Expected; use MailPoet\Config\Updater; class UpdaterTest extends \MailPoetTest { + /** @var Updater */ public $updater; + /** @var string */ public $version; + /** @var string */ public $slug; + /** @var string */ public $pluginName; public function _before() { diff --git a/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php b/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php index e02c762ad1..95d14091af 100644 --- a/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php +++ b/tests/integration/Cron/Workers/KeyCheck/KeyCheckWorkerTest.php @@ -15,6 +15,7 @@ use MailPoetVendor\Carbon\Carbon; require_once('KeyCheckWorkerMockImplementation.php'); class KeyCheckWorkerTest extends \MailPoetTest { + /** @var MockKeyCheckWorker */ public $worker; /** @var ScheduledTaskFactory */ diff --git a/tests/integration/Cron/Workers/SendingQueue/SendingQueueTest.php b/tests/integration/Cron/Workers/SendingQueue/SendingQueueTest.php index e76cfa318d..069d6e5a6e 100644 --- a/tests/integration/Cron/Workers/SendingQueue/SendingQueueTest.php +++ b/tests/integration/Cron/Workers/SendingQueue/SendingQueueTest.php @@ -1042,7 +1042,7 @@ class SendingQueueTest extends \MailPoetTest { return $queue; } - private function getSendingQueueWorker($newsletterRepositoryMock = null, $mailerMock = null) { + private function getSendingQueueWorker($newsletterRepositoryMock = null, $mailerMock = null): SendingQueueWorker { return new SendingQueueWorker( $this->sendingErrorHandler, $this->sendingThrottlingHandler, diff --git a/tests/integration/Cron/Workers/StatsNotifications/AutomatedEmailsTest.php b/tests/integration/Cron/Workers/StatsNotifications/AutomatedEmailsTest.php index 2a5e831e05..f98a668d01 100644 --- a/tests/integration/Cron/Workers/StatsNotifications/AutomatedEmailsTest.php +++ b/tests/integration/Cron/Workers/StatsNotifications/AutomatedEmailsTest.php @@ -177,8 +177,8 @@ class AutomatedEmailsTest extends \MailPoetTest { ->method('render') ->with( $this->anything(), - $this->callback(function($context){ - return strpos($context['linkSettings'], 'mailpoet-settings'); + $this->callback(function($context): bool { + return (bool)strpos($context['linkSettings'], 'mailpoet-settings'); })); $this->cronWorkerRunner->run($this->statsNotifications); diff --git a/tests/integration/Mailer/Methods/AmazonSESTest.php b/tests/integration/Mailer/Methods/AmazonSESTest.php index 5307005a66..0de53938ee 100644 --- a/tests/integration/Mailer/Methods/AmazonSESTest.php +++ b/tests/integration/Mailer/Methods/AmazonSESTest.php @@ -12,6 +12,7 @@ class AmazonSESTest extends \MailPoetTest { public $extraParams; public $newsletter; public $subscriber; + /** @var AmazonSES */ public $mailer; public $returnPath; public $replyTo; diff --git a/tests/integration/Mailer/Methods/MailPoetAPITest.php b/tests/integration/Mailer/Methods/MailPoetAPITest.php index 37dae3d588..3b77220983 100644 --- a/tests/integration/Mailer/Methods/MailPoetAPITest.php +++ b/tests/integration/Mailer/Methods/MailPoetAPITest.php @@ -16,6 +16,7 @@ class MailPoetAPITest extends \MailPoetTest { public $metaInfo; public $newsletter; public $subscriber; + /** @var MailPoet */ public $mailer; public $replyTo; public $sender; @@ -159,7 +160,6 @@ class MailPoetAPITest extends \MailPoetTest { public function testItWillNotSendIfApiKeyIsMarkedInvalid() { if (getenv('WP_TEST_MAILER_ENABLE_SENDING') !== 'true') $this->markTestSkipped(); - $this->mailer->apiKey = 'someapi'; $this->mailer->servicesChecker = Stub::make( new ServicesChecker(), ['isMailPoetAPIKeyValid' => false], diff --git a/tests/integration/Mailer/Methods/PHPMailTest.php b/tests/integration/Mailer/Methods/PHPMailTest.php index 5e3cc358be..7bf37d48bf 100644 --- a/tests/integration/Mailer/Methods/PHPMailTest.php +++ b/tests/integration/Mailer/Methods/PHPMailTest.php @@ -12,6 +12,7 @@ class PHPMailTest extends \MailPoetTest { public $extraParams; public $newsletter; public $subscriber; + /** @var PHPMail */ public $mailer; public $returnPath; public $replyTo; diff --git a/tests/integration/Mailer/Methods/SMTPTest.php b/tests/integration/Mailer/Methods/SMTPTest.php index 591cb5c1c5..f92faff338 100644 --- a/tests/integration/Mailer/Methods/SMTPTest.php +++ b/tests/integration/Mailer/Methods/SMTPTest.php @@ -13,6 +13,7 @@ class SMTPTest extends \MailPoetTest { public $extraParams; public $newsletter; public $subscriber; + /** @var SMTP */ public $mailer; public $returnPath; public $replyTo; diff --git a/tests/integration/Mailer/Methods/SendGridTest.php b/tests/integration/Mailer/Methods/SendGridTest.php index 0d4b8c6edc..ccb9617f3e 100644 --- a/tests/integration/Mailer/Methods/SendGridTest.php +++ b/tests/integration/Mailer/Methods/SendGridTest.php @@ -12,6 +12,7 @@ class SendGridTest extends \MailPoetTest { public $extraParams; public $newsletter; public $subscriber; + /** @var SendGrid */ public $mailer; public $replyTo; public $sender; diff --git a/tests/integration/Services/BridgeTest.php b/tests/integration/Services/BridgeTest.php index 7b4c6cdc5a..88dabc70b2 100644 --- a/tests/integration/Services/BridgeTest.php +++ b/tests/integration/Services/BridgeTest.php @@ -214,7 +214,7 @@ class BridgeTest extends \MailPoetTest { $response = ['state' => Bridge::KEY_VALID]; /** @var Bridge&MockObject $bridge */ $bridge = Stub::makeEmptyExcept( - $this->bridge, + Bridge::class, 'onSettingsSave', [ 'checkMSSKey' => $response, diff --git a/tests/integration/_bootstrap.php b/tests/integration/_bootstrap.php index c64ab50ba3..aab5cb3207 100644 --- a/tests/integration/_bootstrap.php +++ b/tests/integration/_bootstrap.php @@ -177,7 +177,7 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore /** @var EntityManager */ protected $entityManager; - public function setUp() { + public function setUp(): void { $this->diContainer = ContainerWrapper::getInstance(WP_DEBUG); $this->connection = $this->diContainer->get(Connection::class); $this->entityManager = $this->diContainer->get(EntityManager::class); @@ -189,7 +189,7 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore parent::setUp(); } - public function tearDown() { + public function tearDown(): void { $this->entityManager->clear(); parent::tearDown(); }