Fix tests
MAILPOET-5410
This commit is contained in:
committed by
Aschepikov
parent
5f84d5af1c
commit
ee40743a96
@@ -28,6 +28,16 @@ class StatisticsNewsletters {
|
|||||||
$this->subscriber = $subscriber;
|
$this->subscriber = $subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \DateTimeInterface $date
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function withSentAt(\DateTimeInterface $date) {
|
||||||
|
$this->data['sentAt'] = $date;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function create(): StatisticsNewsletterEntity {
|
public function create(): StatisticsNewsletterEntity {
|
||||||
$entityManager = ContainerWrapper::getInstance()->get(EntityManager::class);
|
$entityManager = ContainerWrapper::getInstance()->get(EntityManager::class);
|
||||||
$queue = $this->newsletter->getLatestQueue();
|
$queue = $this->newsletter->getLatestQueue();
|
||||||
@@ -37,6 +47,9 @@ class StatisticsNewsletters {
|
|||||||
$queue,
|
$queue,
|
||||||
$this->subscriber
|
$this->subscriber
|
||||||
);
|
);
|
||||||
|
if (isset($this->data['sentAt'])) {
|
||||||
|
$entity->setSentAt($this->data['sentAt']);
|
||||||
|
}
|
||||||
$entityManager->persist($entity);
|
$entityManager->persist($entity);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
return $entity;
|
return $entity;
|
||||||
|
@@ -12,6 +12,7 @@ use MailPoet\Test\DataFactories\StatisticsNewsletters as StatisticsNewslettersFa
|
|||||||
use MailPoet\Test\DataFactories\StatisticsOpens as StatisticsOpensFacctory;
|
use MailPoet\Test\DataFactories\StatisticsOpens as StatisticsOpensFacctory;
|
||||||
use MailPoet\Test\DataFactories\Subscriber as SubscriberFactory;
|
use MailPoet\Test\DataFactories\Subscriber as SubscriberFactory;
|
||||||
use MailPoetTest;
|
use MailPoetTest;
|
||||||
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
|
|
||||||
class SubscriberStatisticsFieldsFactoryTest extends MailPoetTest {
|
class SubscriberStatisticsFieldsFactoryTest extends MailPoetTest {
|
||||||
public function testItCreatesSentCountField(): void {
|
public function testItCreatesSentCountField(): void {
|
||||||
@@ -22,8 +23,8 @@ class SubscriberStatisticsFieldsFactoryTest extends MailPoetTest {
|
|||||||
$newsletter2 = (new NewsletterFactory())->withSendingQueue()->create();
|
$newsletter2 = (new NewsletterFactory())->withSendingQueue()->create();
|
||||||
(new NewsletterFactory())->withSendingQueue()->create();
|
(new NewsletterFactory())->withSendingQueue()->create();
|
||||||
|
|
||||||
(new StatisticsNewslettersFactory($newsletter1, $subscriber))->create();
|
(new StatisticsNewslettersFactory($newsletter1, $subscriber))->withSentAt(Carbon::now())->create();
|
||||||
(new StatisticsNewslettersFactory($newsletter2, $subscriber))->create();
|
(new StatisticsNewslettersFactory($newsletter2, $subscriber))->withSentAt(Carbon::now())->create();
|
||||||
|
|
||||||
// check definitions
|
// check definitions
|
||||||
$field = $fields['mailpoet:subscriber:email-sent-count'];
|
$field = $fields['mailpoet:subscriber:email-sent-count'];
|
||||||
|
@@ -152,7 +152,7 @@ class SubscribersRepositoryTest extends \MailPoetTest {
|
|||||||
|
|
||||||
$idsToUpdate = [
|
$idsToUpdate = [
|
||||||
$subscriberOne->getId(),
|
$subscriberOne->getId(),
|
||||||
$subscriberTwo->getId(),
|
$subscriberThree->getId(),
|
||||||
];
|
];
|
||||||
$this->repository->bulkUpdateEngagementScoreUpdatedAt($idsToUpdate, null);
|
$this->repository->bulkUpdateEngagementScoreUpdatedAt($idsToUpdate, null);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user