Extract WPFunctions reset to test bootstrap
MAILPOET-5145
This commit is contained in:
committed by
John Oleksowicz
parent
81274b1691
commit
70e6447e28
@ -387,7 +387,6 @@ class AbandonedCartTest extends \MailPoetTest {
|
|||||||
|
|
||||||
public function _after() {
|
public function _after() {
|
||||||
parent::_after();
|
parent::_after();
|
||||||
WPFunctions::set(new WPFunctions());
|
|
||||||
Carbon::setTestNow();
|
Carbon::setTestNow();
|
||||||
// Restore original cart object
|
// Restore original cart object
|
||||||
$this->wooCommerce->cart = $this->cartBackup;
|
$this->wooCommerce->cart = $this->cartBackup;
|
||||||
|
@ -359,9 +359,4 @@ class FirstPurchaseTest extends \MailPoetTest {
|
|||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
return $sendingQueue;
|
return $sendingQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _after() {
|
|
||||||
parent::_after();
|
|
||||||
WPFunctions::set(new WPFunctions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ class PurchasedInCategoryTest extends \MailPoetTest {
|
|||||||
private $segmentsRepository;
|
private $segmentsRepository;
|
||||||
|
|
||||||
public function _before() {
|
public function _before() {
|
||||||
WPFunctions::set(new WPFunctions);
|
|
||||||
WPFunctions::get()->removeAllFilters('woocommerce_payment_complete');
|
WPFunctions::get()->removeAllFilters('woocommerce_payment_complete');
|
||||||
$this->woocommerceHelper = $this->createMock(WCHelper::class);
|
$this->woocommerceHelper = $this->createMock(WCHelper::class);
|
||||||
$this->event = new PurchasedInCategory($this->woocommerceHelper);
|
$this->event = new PurchasedInCategory($this->woocommerceHelper);
|
||||||
|
@ -280,9 +280,4 @@ class PurchasedProductTest extends \MailPoetTest {
|
|||||||
|
|
||||||
return $subscriber;
|
return $subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _after() {
|
|
||||||
parent::_after();
|
|
||||||
WPFunctions::set(new WPFunctions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -112,9 +112,4 @@ class AccessControlTest extends \MailPoetTest {
|
|||||||
|
|
||||||
expect($accessControl->validatePermission($capability))->true();
|
expect($accessControl->validatePermission($capability))->true();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _after() {
|
|
||||||
parent::_after();
|
|
||||||
WPFunctions::set(new WPFunctions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -427,7 +427,6 @@ class SchedulerTest extends \MailPoetTest {
|
|||||||
$scheduledTask = $this->scheduledTasksRepository->findOneBySendingQueue($sendingQueue);
|
$scheduledTask = $this->scheduledTasksRepository->findOneBySendingQueue($sendingQueue);
|
||||||
$this->assertInstanceOf(ScheduledTaskEntity::class, $scheduledTask);
|
$this->assertInstanceOf(ScheduledTaskEntity::class, $scheduledTask);
|
||||||
$this->tester->assertEqualDateTimes($scheduledTask->getScheduledAt(), $currentTime->addMinutes(ScheduledTask::BASIC_RESCHEDULE_TIMEOUT), 1);
|
$this->tester->assertEqualDateTimes($scheduledTask->getScheduledAt(), $currentTime->addMinutes(ScheduledTask::BASIC_RESCHEDULE_TIMEOUT), 1);
|
||||||
WPFunctions::set(new WPFunctions());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItDoesntRunQueueDeliveryWhenMailpoetSubscriberHasUnsubscribed() {
|
public function testItDoesntRunQueueDeliveryWhenMailpoetSubscriberHasUnsubscribed() {
|
||||||
|
@ -56,11 +56,6 @@ class SendPreviewControllerTest extends \MailPoetTest {
|
|||||||
$this->newsletter = $newsletter;
|
$this->newsletter = $newsletter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _after() {
|
|
||||||
parent::_after();
|
|
||||||
WPFunctions::set(new WPFunctions());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testItCanSendAPreview() {
|
public function testItCanSendAPreview() {
|
||||||
$mailer = $this->makeEmpty(Mailer::class, [
|
$mailer = $this->makeEmpty(Mailer::class, [
|
||||||
'send' => Expected::once(
|
'send' => Expected::once(
|
||||||
|
@ -85,11 +85,6 @@ class UserFlagsControllerTest extends \MailPoetTest {
|
|||||||
expect($flag)->null();
|
expect($flag)->null();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _after() {
|
|
||||||
parent::_after();
|
|
||||||
WPFunctions::set(new WPFunctions);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createUserFlag($userId, $name, $value) {
|
private function createUserFlag($userId, $name, $value) {
|
||||||
$flag = new UserFlagEntity();
|
$flag = new UserFlagEntity();
|
||||||
$flag->setUserId($userId);
|
$flag->setUserId($userId);
|
||||||
|
@ -797,7 +797,6 @@ class ImportTest extends \MailPoetTest {
|
|||||||
$data['subscribers'][1][2],
|
$data['subscribers'][1][2],
|
||||||
]]);
|
]]);
|
||||||
expect($newSubscribers)->count(2);
|
expect($newSubscribers)->count(2);
|
||||||
WPFunctions::set(new WPFunctions());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItOnlyAppliesCustomFormatToSitesWithCustomFormat(): void {
|
public function testItOnlyAppliesCustomFormatToSitesWithCustomFormat(): void {
|
||||||
@ -823,7 +822,6 @@ class ImportTest extends \MailPoetTest {
|
|||||||
]]);
|
]]);
|
||||||
expect($newSubscribers)->count(1);
|
expect($newSubscribers)->count(1);
|
||||||
expect($newSubscribers[0]->getEmail())->equals('correctdateformat2@yopmail.com');
|
expect($newSubscribers[0]->getEmail())->equals('correctdateformat2@yopmail.com');
|
||||||
WPFunctions::set(new WPFunctions());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createImportInstance(array $data): Import {
|
private function createImportInstance(array $data): Import {
|
||||||
|
@ -176,9 +176,4 @@ class MailChimpTest extends \MailPoetTest {
|
|||||||
];
|
];
|
||||||
expect($this->mailchimp->isSubscriberAllowed($subscribed))->true();
|
expect($this->mailchimp->isSubscriberAllowed($subscribed))->true();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _after(): void {
|
|
||||||
parent::_after();
|
|
||||||
WPFunctions::set(new WPFunctions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,4 @@ class FunctionsTest extends \MailPoetTest {
|
|||||||
$resultNoRtl = $twig->render('template');
|
$resultNoRtl = $twig->render('template');
|
||||||
expect($resultNoRtl)->isEmpty();
|
expect($resultNoRtl)->isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function _after() {
|
|
||||||
parent::_after();
|
|
||||||
WPFunctions::set(new WPFunctions);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use MailPoet\Cron\CronTrigger;
|
|||||||
use MailPoet\DI\ContainerWrapper;
|
use MailPoet\DI\ContainerWrapper;
|
||||||
use MailPoet\Features\FeaturesController;
|
use MailPoet\Features\FeaturesController;
|
||||||
use MailPoet\Settings\SettingsController;
|
use MailPoet\Settings\SettingsController;
|
||||||
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
use MailPoetVendor\Doctrine\Persistence\Mapping\ClassMetadata;
|
use MailPoetVendor\Doctrine\Persistence\Mapping\ClassMetadata;
|
||||||
@ -97,6 +98,8 @@ abstract class MailPoetTest extends \Codeception\TestCase\Test { // phpcs:ignore
|
|||||||
$this->diContainer = ContainerWrapper::getInstance(WP_DEBUG);
|
$this->diContainer = ContainerWrapper::getInstance(WP_DEBUG);
|
||||||
$this->connection = $this->diContainer->get(Connection::class);
|
$this->connection = $this->diContainer->get(Connection::class);
|
||||||
$this->entityManager = $this->diContainer->get(EntityManager::class);
|
$this->entityManager = $this->diContainer->get(EntityManager::class);
|
||||||
|
// Reset WPFunctions
|
||||||
|
WPFunctions::set(new WPFunctions());
|
||||||
// switch cron to Linux method
|
// switch cron to Linux method
|
||||||
$this->diContainer->get(\MailPoet\Cron\DaemonActionSchedulerRunner::class)->deactivate();
|
$this->diContainer->get(\MailPoet\Cron\DaemonActionSchedulerRunner::class)->deactivate();
|
||||||
$this->diContainer->get(SettingsController::class)->set('cron_trigger.method', CronTrigger::METHOD_LINUX_CRON);
|
$this->diContainer->get(SettingsController::class)->set('cron_trigger.method', CronTrigger::METHOD_LINUX_CRON);
|
||||||
|
Reference in New Issue
Block a user