Fix warnings and errors in integration tests
[PREMIUM-191]
This commit is contained in:
committed by
Jan Jakeš
parent
8eeab7b5cc
commit
f56b58a5fe
@ -401,7 +401,7 @@ class SubscribersTest extends \MailPoetTest {
|
||||
'segment' => $dynamicSegment->getId(),
|
||||
],
|
||||
]);
|
||||
expect($response->meta['filters']['segment'])->contains(['value' => $dynamicSegment->getId(), 'label' => 'Dynamic (1)']);
|
||||
expect($response->meta['filters']['segment'])->contains(['label' => 'Dynamic (1)', 'value' => $dynamicSegment->getId()]);
|
||||
$this->tester->deleteWordPressUser($wpUserEmail);
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,8 @@ class CustomFieldsTest extends \MailPoetTest {
|
||||
'type' => 'text',
|
||||
'params' => [
|
||||
'required' => '1',
|
||||
'label' => 'text custom field',
|
||||
'date_type' => 'year_month_day',
|
||||
'label' => 'text custom field',
|
||||
],
|
||||
]);
|
||||
expect($response)->contains([
|
||||
|
@ -698,8 +698,8 @@ class SubscribersTest extends \MailPoetTest {
|
||||
'settings' => $this->diContainer->get(SettingsController::class),
|
||||
'requiredCustomFieldsValidator' => Stub::makeEmpty(RequiredCustomFieldValidator::class, ['validate']),
|
||||
'subscribeToLists' => Expected::once(function ($subscriberId, $segmentsIds, $options) {
|
||||
expect($options)->contains('send_confirmation_email');
|
||||
expect($options['send_confirmation_email'])->equals(true);
|
||||
expect($options)->hasKey('send_confirmation_email');
|
||||
expect($options['send_confirmation_email'])->equals(1);
|
||||
return [];
|
||||
}),
|
||||
],
|
||||
|
@ -73,19 +73,18 @@ class MenuTest extends \MailPoetTest {
|
||||
|
||||
$wpMock = $this->createMock(WPFunctions::class);
|
||||
$wpMock->method('isPluginActive')->willReturn(true);
|
||||
$wpMock->method('addSubmenuPage')->willReturn(true);
|
||||
|
||||
$accessControlMock = $this->createMock(AccessControl::class);
|
||||
$accessControlMock->method('validatePermission')->willReturn(true);
|
||||
|
||||
$wpMock->expects($this->at(8))->method('addSubmenuPage')->with(
|
||||
null,
|
||||
$this->anything(),
|
||||
$this->anything(),
|
||||
$this->anything(),
|
||||
Menu::AUTOMATIONS_PAGE_SLUG,
|
||||
$this->anything()
|
||||
);
|
||||
$wpMock->expects($this->any())->method('addSubmenuPage')->withConsecutive(
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[$this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything()],
|
||||
[null, $this->anything(), $this->anything(), $this->anything(), Menu::AUTOMATIONS_PAGE_SLUG, $this->anything()]
|
||||
)->willReturn(true);
|
||||
|
||||
$menu = new Menu(
|
||||
$accessControlMock,
|
||||
|
@ -69,15 +69,18 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
'token' => 123,
|
||||
];
|
||||
|
||||
$matcher = $this->any();
|
||||
$cronWorkerRunnerMock = $this->createMock(CronWorkerRunner::class);
|
||||
$cronWorkerRunnerMock
|
||||
->expects($this->at(0))
|
||||
->expects($matcher)
|
||||
->method('run')
|
||||
->willThrowException(new \Exception('Message'));
|
||||
$cronWorkerRunnerMock
|
||||
->expects($this->at(1))
|
||||
->method('run')
|
||||
->willThrowException(new \Exception());
|
||||
->willReturnCallback(function () use ($matcher) {
|
||||
if ($matcher->getInvocationCount() === 1) {
|
||||
throw new \Exception('Message');
|
||||
} else if ($matcher->getInvocationCount() === 2) {
|
||||
throw new \Exception();
|
||||
}
|
||||
});
|
||||
|
||||
$daemon = new Daemon($this->cronHelper, $cronWorkerRunnerMock, $this->createWorkersFactoryMock(), $this->diContainer->get(LoggerFactory::class));
|
||||
$daemonHttpRunner = $this->make(DaemonHttpRunner::class, [
|
||||
@ -213,18 +216,18 @@ class DaemonHttpRunnerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItUpdatesTimestampsDuringExecution() {
|
||||
$matcher = $this->any();
|
||||
$cronWorkerRunnerMock = $this->createMock(CronWorkerRunner::class);
|
||||
$cronWorkerRunnerMock
|
||||
->expects($this->at(0))
|
||||
->expects($matcher)
|
||||
->method('run')
|
||||
->willReturnCallback(function () {
|
||||
sleep(2);
|
||||
->willReturnCallback(function () use ($matcher) {
|
||||
if ($matcher->getInvocationCount() === 1) {
|
||||
sleep(2);
|
||||
} else if ($matcher->getInvocationCount() === 2) {
|
||||
throw new \Exception();
|
||||
}
|
||||
});
|
||||
$cronWorkerRunnerMock
|
||||
->expects($this->at(1))
|
||||
->method('run')
|
||||
->willThrowException(new \Exception());
|
||||
|
||||
$daemon = new Daemon($this->cronHelper, $cronWorkerRunnerMock, $this->createWorkersFactoryMock(), $this->diContainer->get(LoggerFactory::class));
|
||||
$daemonHttpRunner = $this->make(DaemonHttpRunner::class, [
|
||||
'pauseExecution' => null,
|
||||
|
@ -41,18 +41,13 @@ class MailerTest extends \MailPoetTest {
|
||||
|
||||
$mailerFactoryMock = $this->createMock(MailerFactory::class);
|
||||
// First call in constructor
|
||||
$mailerFactoryMock->expects($this->at(0))
|
||||
$mailerFactoryMock->expects($this->exactly(2))
|
||||
->method('buildMailer')
|
||||
->willReturn($this->createMock(Mailer::class));
|
||||
// Second call in custom mailer configuration should be called with sender and reply to from newsletter
|
||||
$mailerFactoryMock->expects($this->at(1))
|
||||
->method('buildMailer')
|
||||
->with(
|
||||
null,
|
||||
['name' => 'Sender', 'address' => 'from@example.com'],
|
||||
['name' => 'Reply-to', 'address' => 'reply-to@example.com']
|
||||
)
|
||||
->willReturn($this->createMock(Mailer::class));
|
||||
->withConsecutive(
|
||||
[$this->anything(), $this->anything(), $this->anything()],
|
||||
// Second call in custom mailer configuration should be called with sender and reply to from newsletter
|
||||
[null, ['name' => 'Sender', 'address' => 'from@example.com'], ['name' => 'Reply-to', 'address' => 'reply-to@example.com']]
|
||||
)->willReturn($this->createMock(Mailer::class));
|
||||
$mailerTask = new MailerTask($mailerFactoryMock);
|
||||
$mailerTask->configureMailer($newsletter);
|
||||
}
|
||||
|
@ -118,15 +118,13 @@ class AutomatedEmailsTest extends \MailPoetTest {
|
||||
|
||||
public function testItRenders() {
|
||||
$this->createNewsletterClicksAndOpens();
|
||||
$this->renderer->expects($this->exactly(2))
|
||||
->method('render');
|
||||
$this->renderer->expects($this->at(0))
|
||||
->method('render')
|
||||
->with($this->equalTo('emails/statsNotificationAutomatedEmails.html'));
|
||||
|
||||
$this->renderer->expects($this->at(1))
|
||||
$this->renderer->expects($this->exactly(2))
|
||||
->method('render')
|
||||
->with($this->equalTo('emails/statsNotificationAutomatedEmails.txt'));
|
||||
->withConsecutive(
|
||||
['emails/statsNotificationAutomatedEmails.html'],
|
||||
['emails/statsNotificationAutomatedEmails.txt']
|
||||
);
|
||||
|
||||
$this->mailer->expects($this->once())
|
||||
->method('send');
|
||||
|
@ -158,16 +158,13 @@ class WorkerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testRendersTemplate() {
|
||||
$this->renderer->expects($this->exactly(2))
|
||||
->method('render');
|
||||
$this->renderer->expects($this->at(0))
|
||||
$matcher = $this->exactly(2);
|
||||
$this->renderer->expects($matcher)
|
||||
->method('render')
|
||||
->with($this->equalTo('emails/statsNotification.html'));
|
||||
|
||||
$this->renderer->expects($this->at(1))
|
||||
->method('render')
|
||||
->with($this->equalTo('emails/statsNotification.txt'));
|
||||
|
||||
->withConsecutive(
|
||||
['emails/statsNotification.html'],
|
||||
['emails/statsNotification.txt']
|
||||
);
|
||||
$this->statsNotifications->process();
|
||||
}
|
||||
|
||||
|
@ -301,15 +301,13 @@ class WordpressMailerTest extends \MailPoetTest {
|
||||
*/
|
||||
public function testItChangesReplyToEmailOnDifferentCalls() {
|
||||
$mailerFactory = $this->getMailerFactoryInstanceForReplyToTests();
|
||||
$mailerFactory->expects($this->at(0))
|
||||
|
||||
$mailerFactory->expects($this->exactly(2))
|
||||
->method('buildMailer')
|
||||
->with($this->isNull(), $this->isNull(), $this->equalTo([
|
||||
'address' => 'reply-to@example.com',
|
||||
'name' => 'Reply To',
|
||||
]));
|
||||
$mailerFactory->expects($this->at(1))
|
||||
->method('buildMailer')
|
||||
->with($this->isNull(), $this->isNull(), $this->isNull());
|
||||
->withConsecutive(
|
||||
[null, null, ['address' => 'reply-to@example.com', 'name' => 'Reply To',]],
|
||||
[null, null, null]
|
||||
);
|
||||
|
||||
$wpMailer = new WordPressMailer($mailerFactory, new MetaInfo, $this->subscribersRepository);
|
||||
$wpMailer->addAddress('email@example.com', 'Full Name');
|
||||
|
Reference in New Issue
Block a user