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() {
|
||||
parent::_after();
|
||||
WPFunctions::set(new WPFunctions());
|
||||
Carbon::setTestNow();
|
||||
// Restore original cart object
|
||||
$this->wooCommerce->cart = $this->cartBackup;
|
||||
|
@ -359,9 +359,4 @@ class FirstPurchaseTest extends \MailPoetTest {
|
||||
$this->entityManager->flush();
|
||||
return $sendingQueue;
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
parent::_after();
|
||||
WPFunctions::set(new WPFunctions);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ class PurchasedInCategoryTest extends \MailPoetTest {
|
||||
private $segmentsRepository;
|
||||
|
||||
public function _before() {
|
||||
WPFunctions::set(new WPFunctions);
|
||||
WPFunctions::get()->removeAllFilters('woocommerce_payment_complete');
|
||||
$this->woocommerceHelper = $this->createMock(WCHelper::class);
|
||||
$this->event = new PurchasedInCategory($this->woocommerceHelper);
|
||||
|
@ -280,9 +280,4 @@ class PurchasedProductTest extends \MailPoetTest {
|
||||
|
||||
return $subscriber;
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
parent::_after();
|
||||
WPFunctions::set(new WPFunctions);
|
||||
}
|
||||
}
|
||||
|
@ -112,9 +112,4 @@ class AccessControlTest extends \MailPoetTest {
|
||||
|
||||
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);
|
||||
$this->assertInstanceOf(ScheduledTaskEntity::class, $scheduledTask);
|
||||
$this->tester->assertEqualDateTimes($scheduledTask->getScheduledAt(), $currentTime->addMinutes(ScheduledTask::BASIC_RESCHEDULE_TIMEOUT), 1);
|
||||
WPFunctions::set(new WPFunctions());
|
||||
}
|
||||
|
||||
public function testItDoesntRunQueueDeliveryWhenMailpoetSubscriberHasUnsubscribed() {
|
||||
|
@ -56,11 +56,6 @@ class SendPreviewControllerTest extends \MailPoetTest {
|
||||
$this->newsletter = $newsletter;
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
parent::_after();
|
||||
WPFunctions::set(new WPFunctions());
|
||||
}
|
||||
|
||||
public function testItCanSendAPreview() {
|
||||
$mailer = $this->makeEmpty(Mailer::class, [
|
||||
'send' => Expected::once(
|
||||
|
@ -85,11 +85,6 @@ class UserFlagsControllerTest extends \MailPoetTest {
|
||||
expect($flag)->null();
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
parent::_after();
|
||||
WPFunctions::set(new WPFunctions);
|
||||
}
|
||||
|
||||
private function createUserFlag($userId, $name, $value) {
|
||||
$flag = new UserFlagEntity();
|
||||
$flag->setUserId($userId);
|
||||
|
@ -797,7 +797,6 @@ class ImportTest extends \MailPoetTest {
|
||||
$data['subscribers'][1][2],
|
||||
]]);
|
||||
expect($newSubscribers)->count(2);
|
||||
WPFunctions::set(new WPFunctions());
|
||||
}
|
||||
|
||||
public function testItOnlyAppliesCustomFormatToSitesWithCustomFormat(): void {
|
||||
@ -823,7 +822,6 @@ class ImportTest extends \MailPoetTest {
|
||||
]]);
|
||||
expect($newSubscribers)->count(1);
|
||||
expect($newSubscribers[0]->getEmail())->equals('correctdateformat2@yopmail.com');
|
||||
WPFunctions::set(new WPFunctions());
|
||||
}
|
||||
|
||||
private function createImportInstance(array $data): Import {
|
||||
|
@ -176,9 +176,4 @@ class MailChimpTest extends \MailPoetTest {
|
||||
];
|
||||
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');
|
||||
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\Features\FeaturesController;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||
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->connection = $this->diContainer->get(Connection::class);
|
||||
$this->entityManager = $this->diContainer->get(EntityManager::class);
|
||||
// Reset WPFunctions
|
||||
WPFunctions::set(new WPFunctions());
|
||||
// switch cron to Linux method
|
||||
$this->diContainer->get(\MailPoet\Cron\DaemonActionSchedulerRunner::class)->deactivate();
|
||||
$this->diContainer->get(SettingsController::class)->set('cron_trigger.method', CronTrigger::METHOD_LINUX_CRON);
|
||||
|
Reference in New Issue
Block a user