Fix PHPUnit 6 & Codeception\Verify incompatibilities
[MAILPOET-2582]
This commit is contained in:
committed by
Jack Kitterhing
parent
aa05ae4132
commit
835d8bc0af
@ -502,7 +502,7 @@ class APITest extends \MailPoetTest {
|
||||
'email' => 'test@example.com',
|
||||
];
|
||||
|
||||
$this->setExpectedException('Exception');
|
||||
$this->expectException('Exception');
|
||||
$this->getApi()->addSubscriber($subscriber);
|
||||
}
|
||||
|
||||
@ -568,7 +568,7 @@ class APITest extends \MailPoetTest {
|
||||
'email' => 'test@example.com',
|
||||
];
|
||||
$segments = [$segment->id()];
|
||||
$this->setExpectedException('\Exception');
|
||||
$this->expectException('\Exception');
|
||||
$API->addSubscriber($subscriber, $segments, ['schedule_welcome_email' => true, 'send_confirmation_email' => false]);
|
||||
}
|
||||
|
||||
@ -649,7 +649,8 @@ class APITest extends \MailPoetTest {
|
||||
$subscriber = [
|
||||
'email' => 'test@example.com',
|
||||
];
|
||||
$this->setExpectedException('\Exception', 'Subscriber added to lists, but confirmation email failed to send: big error');
|
||||
$this->expectException('\Exception');
|
||||
$this->expectExceptionMessage('Subscriber added to lists, but confirmation email failed to send: big error');
|
||||
$API->addSubscriber($subscriber, [$segment->id], ['send_confirmation_email' => true]);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ use MailPoet\Tasks\Sending;
|
||||
use MailPoet\WooCommerce\Helper as WCHelper;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class PurchasedInCategoryTest extends \MailPoetTest {
|
||||
|
||||
|
@ -120,7 +120,8 @@ class InactiveSubscribersTest extends \MailPoetTest {
|
||||
], $this);
|
||||
|
||||
$worker = new InactiveSubscribers($controllerMock, $this->settings);
|
||||
$this->setExpectedException(\Exception::class, 'Maximum execution time has been reached.');
|
||||
$this->expectException(\Exception::class);
|
||||
$this->expectExceptionMessage('Maximum execution time has been reached.');
|
||||
$worker->processTaskStrategy(ScheduledTask::createOrUpdate([]), microtime(true) - $this->cronHelper->getDaemonExecutionLimit());
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use MailPoet\Cron\Workers\KeyCheck\PremiumKeyCheck;
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Settings\SettingsRepository;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class PremiumKeyCheckTest extends \MailPoetTest {
|
||||
public $worker;
|
||||
|
@ -9,7 +9,7 @@ use MailPoet\Mailer\Mailer;
|
||||
use MailPoet\Services\Bridge;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Settings\SettingsRepository;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class SendingServiceKeyCheckTest extends \MailPoetTest {
|
||||
public $worker;
|
||||
|
@ -12,7 +12,7 @@ use MailPoet\Models\StatisticsWooCommercePurchases;
|
||||
use MailPoet\Statistics\Track\WooCommercePurchases;
|
||||
use MailPoet\WooCommerce\Helper as WooCommerceHelper;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class WooCommerceOrdersTest extends \MailPoetTest {
|
||||
/** @var MockObject */
|
||||
|
@ -5,7 +5,7 @@ namespace MailPoet\DynamicSegments\FreePluginConnectors;
|
||||
use Codeception\Stub;
|
||||
use Codeception\Stub\Expected;
|
||||
use MailPoet\Models\DynamicSegment;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class AddToNewslettersSegmentsTest extends \MailPoetTest {
|
||||
|
||||
|
@ -5,7 +5,7 @@ namespace MailPoet\DynamicSegments\FreePluginConnectors;
|
||||
use Codeception\Stub;
|
||||
use Codeception\Stub\Expected;
|
||||
use MailPoet\Models\DynamicSegment;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class AddToSubscribersFiltersTest extends \MailPoetTest {
|
||||
|
||||
|
@ -8,7 +8,7 @@ use MailPoet\DynamicSegments\Persistence\Loading\SubscribersIds;
|
||||
use MailPoet\Models\DynamicSegment;
|
||||
use MailPoet\Models\Segment;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class SendingNewslettersSubscribersFinderTest extends \MailPoetTest {
|
||||
|
||||
|
@ -19,7 +19,7 @@ class FormDataMapperTest extends \MailPoetTest {
|
||||
'description' => '',
|
||||
'segmentType' => '',
|
||||
];
|
||||
$this->setExpectedException('\MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException');
|
||||
$this->expectException('\MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException');
|
||||
$this->mapper->mapDataToDB($data);
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ class FormDataMapperTest extends \MailPoetTest {
|
||||
'description' => '',
|
||||
'segmentType' => 'invalid',
|
||||
];
|
||||
$this->setExpectedException('\MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException');
|
||||
$this->expectException('\MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException');
|
||||
$this->mapper->mapDataToDB($data);
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ class FormDataMapperTest extends \MailPoetTest {
|
||||
$this->assertInstanceOf('\MailPoet\Models\DynamicSegment', $segment);
|
||||
$this->assertEquals('Name', $segment->name);
|
||||
$this->assertEquals('Description', $segment->description);
|
||||
$this->assertNull($segment->id);
|
||||
$this->assertTrue($segment->id === null);
|
||||
$this->assertCount(1, $segment->getFilters());
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ class FormDataMapperTest extends \MailPoetTest {
|
||||
'description' => 'Description',
|
||||
'segmentType' => 'woocommerce',
|
||||
];
|
||||
$this->setExpectedException('\MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException');
|
||||
$this->expectException('\MailPoet\DynamicSegments\Exceptions\InvalidSegmentTypeException');
|
||||
$this->mapper->mapDataToDB($data);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ class FormDataMapperTest extends \MailPoetTest {
|
||||
$this->assertInstanceOf('\MailPoet\Models\DynamicSegment', $segment);
|
||||
$this->assertEquals('Name', $segment->name);
|
||||
$this->assertEquals('Description', $segment->description);
|
||||
$this->assertNull($segment->id);
|
||||
$this->assertTrue($segment->id === null);
|
||||
$filters = $segment->getFilters();
|
||||
$this->assertCount(1, $filters);
|
||||
$this->assertInstanceOf('\MailPoet\DynamicSegments\Filters\WooCommerceCategory', $filters[0]);
|
||||
@ -88,7 +88,7 @@ class FormDataMapperTest extends \MailPoetTest {
|
||||
$this->assertInstanceOf('\MailPoet\Models\DynamicSegment', $segment);
|
||||
$this->assertEquals('Name', $segment->name);
|
||||
$this->assertEquals('Description', $segment->description);
|
||||
$this->assertNull($segment->id);
|
||||
$this->assertTrue($segment->id === null);
|
||||
$filters = $segment->getFilters();
|
||||
$this->assertCount(1, $filters);
|
||||
$this->assertInstanceOf('\MailPoet\DynamicSegments\Filters\WooCommerceProduct', $filters[0]);
|
||||
|
@ -38,7 +38,7 @@ class SingleSegmentLoaderTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItThrowsForUnknownSegment() {
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->loader->load($this->segment->id + 11564564);
|
||||
}
|
||||
|
||||
|
@ -7,10 +7,11 @@ require_once(ABSPATH . 'wp-admin/includes/user.php');
|
||||
use MailPoet\DynamicSegments\Filters\UserRole;
|
||||
use MailPoet\DynamicSegments\RequirementsChecker;
|
||||
use MailPoet\Models\DynamicSegment;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class SubscribersCountTest extends \MailPoetTest {
|
||||
|
||||
/** @var RequirementsChecker|\PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var RequirementsChecker|MockObject */
|
||||
private $requirementChecker;
|
||||
|
||||
public function _before() {
|
||||
|
@ -8,12 +8,13 @@ use MailPoet\DynamicSegments\Filters\UserRole;
|
||||
use MailPoet\DynamicSegments\RequirementsChecker;
|
||||
use MailPoet\Models\DynamicSegment;
|
||||
use MailPoet\Models\Subscriber;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class SubscribersIdsTest extends \MailPoetTest {
|
||||
|
||||
private $editorsWpIds = [];
|
||||
|
||||
/** @var RequirementsChecker|\PHPUnit_Framework_MockObject_MockObject */
|
||||
/** @var RequirementsChecker|MockObject */
|
||||
private $requirementChecker;
|
||||
|
||||
public function _before() {
|
||||
|
@ -160,7 +160,7 @@ class MailerLogTest extends \MailPoetTest {
|
||||
expect($mailerLog['retry_at'])->null();
|
||||
expect($mailerLog['error'])->null();
|
||||
// retry attempt should be incremented, error logged, retry attempt scheduled
|
||||
$this->setExpectedException('\Exception');
|
||||
$this->expectException('\Exception');
|
||||
MailerLog::processError($operation = 'send', $error = 'email rejected');
|
||||
$mailerLog = MailerLog::getMailerLog();
|
||||
expect($mailerLog['retry_attempt'])->equals(1);
|
||||
@ -178,7 +178,7 @@ class MailerLogTest extends \MailPoetTest {
|
||||
expect($mailerLog['retry_attempt'])->null();
|
||||
expect($mailerLog['retry_at'])->null();
|
||||
expect($mailerLog['error'])->null();
|
||||
$this->setExpectedException('\Exception');
|
||||
$this->expectException('\Exception');
|
||||
MailerLog::processNonBlockingError($operation = 'send', $error = 'email rejected');
|
||||
$mailerLog = MailerLog::getMailerLog();
|
||||
expect($mailerLog['retry_attempt'])->equals(1);
|
||||
|
@ -5,7 +5,7 @@ namespace MailPoet\Test\Newsletter\Editor;
|
||||
use Codeception\Stub\Expected;
|
||||
use MailPoet\Newsletter\Editor\PostTransformer;
|
||||
use MailPoet\Newsletter\Editor\PostTransformerContentsExtractor;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class PostContentTransformerTest extends \MailPoetTest {
|
||||
/** @var array */
|
||||
|
@ -8,7 +8,7 @@ use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Models\SubscriberSegment;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
require_once('SubscribersBulkActionHandlerMock.php');
|
||||
|
||||
@ -57,7 +57,7 @@ class BulkActionTest extends \MailPoetTest {
|
||||
|
||||
public function testBulkActionWithoutSegment() {
|
||||
$handler = new BulkAction([]);
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$handler->apply();
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ class BulkActionTest extends \MailPoetTest {
|
||||
'listing' => ['filter' => ['segment' => $this->segment2->id]],
|
||||
'action' => 'trash',
|
||||
]);
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
remove_all_filters('mailpoet_subscribers_in_segment_apply_bulk_action_handlers');
|
||||
$handler->apply();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use MailPoet\Models\SubscriberSegment;
|
||||
use MailPoet\Tasks\Sending as SendingTask;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class SubscribersFinderTest extends \MailPoetTest {
|
||||
public $sending;
|
||||
|
@ -11,7 +11,7 @@ use MailPoet\Models\Subscriber;
|
||||
use MailPoet\Models\SubscriberSegment;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class SubscribersListingsTest extends \MailPoetTest {
|
||||
public $subscriber2;
|
||||
@ -61,7 +61,7 @@ class SubscribersListingsTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testTryToGetListingsWithoutPassingSegment() {
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->finder->getListingsInSegment([]);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ class SubscribersListingsTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testTryToGetListingsForSegmentWithoutHandler() {
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
remove_all_filters('mailpoet_get_subscribers_listings_in_segment_handlers');
|
||||
$this->finder->getListingsInSegment(['filter' => ['segment' => $this->segment2->id]]);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ use MailPoet\Services\Bridge\BridgeTestMockAPI as MockAPI;
|
||||
use MailPoet\Settings\SettingsController;
|
||||
use MailPoet\Settings\SettingsRepository;
|
||||
use MailPoet\WP\Functions as WPFunctions;
|
||||
use PHPUnit_Framework_MockObject_MockObject as MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
require_once('BridgeTestMockAPI.php');
|
||||
|
||||
|
@ -14,7 +14,7 @@ use MailPoet\Tasks\Sending;
|
||||
use MailPoet\Util\Cookies;
|
||||
use MailPoet\WooCommerce\Helper as WooCommerceHelper;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
use PHPUnit_Framework_MockObject_MockObject;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use WC_Order;
|
||||
|
||||
class WooCommercePurchasesTest extends \MailPoetTest {
|
||||
@ -321,7 +321,7 @@ class WooCommercePurchasesTest extends \MailPoetTest {
|
||||
return $click->save();
|
||||
}
|
||||
|
||||
private function createWooCommerceHelperMock(PHPUnit_Framework_MockObject_MockObject $orderMock) {
|
||||
private function createWooCommerceHelperMock(MockObject $orderMock) {
|
||||
$mock = $this->createMock(WooCommerceHelper::class);
|
||||
$mock->method('wcGetOrder')->willReturn($orderMock);
|
||||
return $mock;
|
||||
|
@ -22,7 +22,7 @@ class RequiredCustomFieldValidatorTest extends \MailPoetTest {
|
||||
|
||||
public function testItValidatesDataWithoutCustomField() {
|
||||
$validator = new RequiredCustomFieldValidator();
|
||||
$this->setExpectedException('Exception');
|
||||
$this->expectException('Exception');
|
||||
$validator->validate([]);
|
||||
}
|
||||
|
||||
@ -38,13 +38,13 @@ class RequiredCustomFieldValidatorTest extends \MailPoetTest {
|
||||
|
||||
public function testItValidatesDataWithEmptyCustomField() {
|
||||
$validator = new RequiredCustomFieldValidator();
|
||||
$this->setExpectedException('Exception');
|
||||
$this->expectException('Exception');
|
||||
$validator->validate([$this->customField->id() => '']);
|
||||
}
|
||||
|
||||
public function testItValidatesDataWithEmptyCustomFieldAsCFId() {
|
||||
$validator = new RequiredCustomFieldValidator();
|
||||
$this->setExpectedException('Exception');
|
||||
$this->expectException('Exception');
|
||||
$validator->validate(['cf_' . $this->customField->id() => '']);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ class SourceTest extends \MailPoetTest {
|
||||
$subscriber = Subscriber::createOrUpdate([
|
||||
'source' => Source::UNKNOWN,
|
||||
]);
|
||||
$this->setExpectedException('\InvalidArgumentException');
|
||||
$this->expectException('\InvalidArgumentException');
|
||||
Source::setSource($subscriber, 'invalid source');
|
||||
}
|
||||
|
||||
|
@ -224,19 +224,19 @@ class TransactionalEmailsTest extends \MailPoetTest {
|
||||
);
|
||||
$transactionalEmails->useTemplateForWoocommerceEmails();
|
||||
expect($addedActions)->count(1);
|
||||
expect($addedActions['woocommerce_init'])->isCallable();
|
||||
expect($addedActions['woocommerce_init'])->callable();
|
||||
$addedActions['woocommerce_init']();
|
||||
expect($removedActions)->count(2);
|
||||
expect($addedActions)->count(4);
|
||||
expect($addedActions['woocommerce_email_header'])->isCallable();
|
||||
expect($addedActions['woocommerce_email_header'])->callable();
|
||||
ob_start();
|
||||
$addedActions['woocommerce_email_header']('heading text');
|
||||
expect(ob_get_clean())->equals('HTML before content with heading text');
|
||||
expect($addedActions['woocommerce_email_footer'])->isCallable();
|
||||
expect($addedActions['woocommerce_email_footer'])->callable();
|
||||
ob_start();
|
||||
$addedActions['woocommerce_email_footer']();
|
||||
expect(ob_get_clean())->equals('HTML after content');
|
||||
expect($addedActions['woocommerce_email_styles'])->isCallable();
|
||||
expect($addedActions['woocommerce_email_styles'])->callable();
|
||||
expect($addedActions['woocommerce_email_styles']('some css'))->equals('prefixed some css');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user