Commit Graph

66 Commits

Author SHA1 Message Date
Rostislav Wolny
5fdba0e170 Replace current_time usage in tests
[MAILPOET-6142]
2024-08-19 15:29:42 +02:00
Rostislav Wolny
a7df6b496f Add logging for unexpected states when we reach the end of sending
[MAILPOET-5881]
2024-06-07 11:32:46 +02:00
Rostislav Wolny
9dd808a070 Set as invalid only for non-campaign email types
For non-campaign emails, we use scheduled tasks to display processed stats.
The invalid tasks are no longer processed, and they don't block the queue
and are not counted in the stats.
For campaign emails (bulk emails), we just mark them as sent to zero recipients.
[MAILPOET-5881]
2024-06-07 11:32:46 +02:00
Rostislav Wolny
e4cff6c14f Remove an unnecessary condition in the batch processing loop
The batch will be continued anyway because of the next condition
if (!$queue->getCountToProcess()) {
  continue;
}
The newsletter entity will be marked as sent (plus other stuff related to finished sending)
after the loop in $this->endSending.
2024-06-07 11:32:46 +02:00
Jan Jakes
4c1b2e46c8 Trigger automation email sent hook for automation emails
[MAILPOET-4977]
2024-05-06 12:39:00 +02:00
Mike Jolley
0d6fe6e5eb Apply rules to tests and tasks 2024-03-21 16:57:59 +01:00
Rostislav Wolny
749c4e5e43 Prevent deleting and further changes in detached tasks during sending
When a post notification history is deleted in
MailPoet\Cron\Workers\SendingQueue\Tasks\Newsletter::preProcessNewsletter
it is also detached from EntityManager.

Any further attempt to manipulate the entity via EntityManager (remove or flush) causes
errors like "ERROR: A new entity was found through the relationship 'MailPoet\Entities\ScheduledTaskEntity#sendingQueue'"

In this commit we prevent doing such changes.
[MAILPOET-5880]
2024-02-05 15:16:11 +01:00
Brezo Cordero
42618ab15c Pause sending task if sender address not valid
[MAILPOET-5832]
2024-01-20 13:39:23 +05:00
Rodrigo Primo
1a1f48eb15 Replace SendingQueue model with Doctrine in SendingQueueTest
I opted to remove testItDeletesQueueWhenNewsletterIsNotFound() as I
wasn't sure how to recreate this test using Doctrine and I found out
that it was actually not working. The call to
$this->newslettersRepository->bulkDelete() was deleting the sending
queue entry and not SendingQueue::deleteTaskIfNewsletterDoesNotExist().

[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
33769e703c Replace StatisticsNewsletters model with Doctrine in SendingQueue
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
4fe642916e Replace Newsletter model with Doctrine in SendingQueue
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
83826b3f65 Replace Subscriber model with Doctrine in SendingQueue and SendingQueueTest
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
5ac874c713 Replace Newsletter and NewsletterSegment models with Doctrine
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
9725e300f3 Fix bug in testItCanProcessWelcomeNewsletters() test
This test was checking that the status of a welcome email is set to
`sent` after it is processed. Turns out this is not what should happen
and also not what is actually happen. The code only changes the status
of emails of the types standard and notification history:

7d43059f15/mailpoet/lib/Cron/Workers/SendingQueue/Tasks/Newsletter.php (L285-L286)

The test changes the type of the email to welcome
using Paris and never persists it to the database. The code mentioned
above that changes the status of the email uses Doctrine, so it was
still acting as if this was an standard email and not a welcome email.

To fix this problem, I updated the test to check if the status of the
welcome email is `active` and also made sure to persist the change to
the database and refresh the Doctrine entity.

[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
4f333e3ae8 Replace StatisticsNewsletters model with Doctrine
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
a9952cf394 Replace Segment model with Doctrine in SendingQueueTest
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
abd19a6e6e Replace SubscriberSegment model with Doctrine in SendingQueueTest
[MAILPOET-5737]
2024-01-17 22:32:37 +05:00
Rodrigo Primo
e96251db7e Fix bug when changing ScheduledTask in_progress field
In 3394568, SendingQueue::stopProgress() was refactored to use Doctrine
but a typo introduced a bug causing this method to set
ScheduledTaskEntity::inProgress to true instead of false:

3394568792 (diff-3a26b2d8faf9cc01efd5aef47b058c088c0de01b8074c3be7cefd9adb77fbaaaR551)

This luckly was caught by the
EditorCouponCest.php:seeNoticeWhenCouponCantGenerateAndResumeSending
acceptance test.

This commit fixes the problem and also adds two integration tests to
protect against similar regressions in the future.

[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
0604d97212 Improve test coverage for SendingQueue::processSending()
While working on the previous commit, I noticed that we had a test to
check removing subscribers that are not part of a segment associated
with a newsletter when sending
(testItRemovesSubscribersFromProcessingListWhenNewsletterHasSegmentAndSubscriberIsNotPartOfIt()).
But SendingQueue::processSending() also handles removing subscribers
when sending newsletters without segments. And there was not test to
cover this part of the code.

[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
876a9489a4 Replace \MailPoet\Tasks\Sending with Doctrine in SendingQueueTest
This commit also removes Sending::getSendingQueueEntity() as the last
calls to this method were removed when refactoring SendingQueueTest.

[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
75f7ea24a9 Rename createQueueWithTaskAndSegment() to createQueueWithTask()
Removed `AndSegment` from test helper method to better reflect what it does as it does not create a segment.

[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
7bb40664cc Replace ScheduledTask model with Doctrine in SendingQueueTest
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
5891e09418 Replace simple uses of Newsletter and Subscriber models with Doctrine
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
90b56d3aa8 Replace model ScheduledTaskSubscriber with Doctrine in SendingQueueTest
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
d2e226a932 Fix SendingQueueTests after Doctrine refactor
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Rodrigo Primo
3b38b3034a Update calls to SendingQueue worker constructor in SendingQueueTest
[MAILPOET-5682]
2024-01-12 13:25:46 +01:00
Jan Lysý
41a55262fe Fix PHPStan warnings in tests
[MAILPOET-5751]
2023-12-13 11:48:14 +01:00
Jan Jakes
bb29f25c40 Remove simple usages of MailPoet\Tasks\Sending from integration tests
[MAILPOET-4375]
2023-11-02 12:53:36 +01:00
Rodrigo Primo
2b368141db Refactor updateProcessedSubscribers() to use Doctrine instead of Paris
It was necessary to update a test to be more lenient when comparing
dates and another one to persist a change in Paris to the database.

[MAILPOET-4368]
2023-10-25 21:09:39 +02:00
Rodrigo Primo
2ced2b4afa Replace expect()->lessThan() with verify()->lessThan()
codeception/verify 2.1 removed support for expect()->lessThan() so we need
to replace it with verify()->lessThan().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
Rodrigo Primo
525495409c Replace expect()->notNull() with verify()->notNull()
codeception/verify 2.1 removed support for expect()->notNull() so we need
to replace it with verify()->notNull().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
Rodrigo Primo
9b56fdc688 Replace expect()->count() with verify()->arrayCount()
codeception/verify 2.1 removed support for expect()->count() so we need
to replace it with verify()->arrayCount().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
Rodrigo Primo
00c5250cff Replace expect()->notEquals() with verify()->notEquals()
codeception/verify 2.1 removed support for expect()->notEquals() so we need
to replace it with verify()->notEquals().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
Rodrigo Primo
709be1d541 Replace expect()->null() with verify()->null()
codeception/verify 2.1 removed support for expect()->null() so we need
to replace it with verify()->null().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
Rodrigo Primo
997f635d4a Replace expect()->false() with verify()->false()
codeception/verify 2.1 removed support for expect()->false() so we need
to replace it with verify()->false().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
Rodrigo Primo
9adbf81a78 Replace expect()->true() with verify()->true()
codeception/verify 2.1 removed support for expect()->true() so we need
to replace it with verify()->true().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
Rodrigo Primo
afe378ba22 Replace expect()->equals() with verify()->equals()
codeception/verify 2.1 removed support for expect()->equals() so we need
to replace it with verify()->equals().

[MAILPOET-5664]
2023-10-24 08:58:22 +03:00
John Oleksowicz
021d8774e7 Wrap bulk updates in a transaction
MAILPOET-5410
2023-08-11 16:39:57 +02:00
alex-mailpoet
764114edc7 Replace two counting DB queries with arithmetic in sending loop
[MAILPOET-5178]
2023-07-03 16:52:46 +02:00
John Oleksowicz
b22217420f Track last sending at
MAILPOET-4998
2023-06-22 15:29:22 +02:00
Jan Jakes
69f21814e3 Rename "transactional" email type to "automation_transactional"
[MAILPOET-5258]
2023-04-24 09:54:08 +03:00
David Remer
47fed85953 Test SendingQueue sends transactional emails as expected
[MAILPOET-4999]
2023-04-17 13:59:39 +02:00
John Oleksowicz
33f744e9be Simplify problematic test
MAILPOET-5145
2023-04-07 12:11:12 -05:00
John Oleksowicz
c75bc388c9 Remove unnecessary cleanup code
MAILPOET-5145
2023-04-07 12:11:12 -05:00
John Oleksowicz
57eb438eb8 Don't assume auto increment of 1
MAILPOET-5145
2023-04-07 12:11:12 -05:00
Sam Najian
cb786ee57f Write acceptance test to replicate the bug
[MAILPOET-5134]
2023-04-03 11:53:49 +02:00
Jan Lysý
71aef99607 Remove usage Sending::createFromQueue from SendingQueue worker test
[MAILPOET-4369]
2023-03-02 12:39:35 +02:00
Sam Najian
fdf0875905 Pause sending queue when encountering a corrupt newsletter
[MAILPOET-4983]
2023-03-01 17:46:22 +01:00
John Oleksowicz
49c85c05ed Move campaignId generation to more logical place
MAILPOET-5034
2023-02-26 15:20:48 +01:00
John Oleksowicz
a6824cce36 Add tests for campaignId generation
[MAILPOET-5033]
2023-02-26 15:20:48 +01:00