Replace NewsletterLink with NewsletterLinkEntity in the class SendingQueueTest

[MAILPOET-3816]
This commit is contained in:
Rodrigo Primo
2021-10-26 17:19:46 -03:00
committed by Veljko V
parent 511556549b
commit b5ac7dd507

View File

@@ -28,7 +28,6 @@ use MailPoet\Entities\SubscriberSegmentEntity;
use MailPoet\Logging\LoggerFactory; use MailPoet\Logging\LoggerFactory;
use MailPoet\Mailer\MailerLog; use MailPoet\Mailer\MailerLog;
use MailPoet\Models\Newsletter; use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterLink;
use MailPoet\Models\NewsletterSegment; use MailPoet\Models\NewsletterSegment;
use MailPoet\Models\ScheduledTask; use MailPoet\Models\ScheduledTask;
use MailPoet\Models\ScheduledTaskSubscriber; use MailPoet\Models\ScheduledTaskSubscriber;
@@ -126,19 +125,28 @@ class SendingQueueTest extends \MailPoetTest {
$this->queue->setSubscribers([$this->subscriber->getId()]); $this->queue->setSubscribers([$this->subscriber->getId()]);
$this->queue->countCotal = 1; $this->queue->countCotal = 1;
$this->queue->save(); $this->queue->save();
$this->newsletterLink = NewsletterLink::create();
$this->newsletterLink->newsletterId = $this->newsletter->id; $this->newslettersRepository = $this->diContainer->get(NewslettersRepository::class);
$this->newsletterLink->queueId = $this->queue->id;
$this->newsletterLink->url = '[link:subscription_instant_unsubscribe_url]'; $newsletterEntity = $this->newslettersRepository->findOneById($this->newsletter->id);
$this->newsletterLink->hash = 'abcde'; $this->assertInstanceOf(NewsletterEntity::class, $newsletterEntity);
$this->newsletterLink->save(); $queue = $newsletterEntity->getLatestQueue();
$this->assertInstanceOf(SendingQueueEntity::class, $queue);
$this->newsletterLink = new NewsletterLinkEntity(
$newsletterEntity,
$queue,
'[link:subscription_instant_unsubscribe_url]',
'abcde'
);
$this->entityManager->persist($this->newsletterLink);
$this->entityManager->flush();
$this->subscribersFinder = $this->diContainer->get(SubscribersFinder::class); $this->subscribersFinder = $this->diContainer->get(SubscribersFinder::class);
$this->sendingErrorHandler = $this->diContainer->get(SendingErrorHandler::class); $this->sendingErrorHandler = $this->diContainer->get(SendingErrorHandler::class);
$this->sendingThrottlingHandler = $this->diContainer->get(SendingThrottlingHandler::class); $this->sendingThrottlingHandler = $this->diContainer->get(SendingThrottlingHandler::class);
$this->statsNotificationsWorker = Stub::makeEmpty(StatsNotificationsScheduler::class); $this->statsNotificationsWorker = Stub::makeEmpty(StatsNotificationsScheduler::class);
$this->loggerFactory = LoggerFactory::getInstance(); $this->loggerFactory = LoggerFactory::getInstance();
$this->cronHelper = $this->diContainer->get(CronHelper::class); $this->cronHelper = $this->diContainer->get(CronHelper::class);
$this->newslettersRepository = $this->diContainer->get(NewslettersRepository::class);
$this->segmentsRepository = $this->diContainer->get(SegmentsRepository::class); $this->segmentsRepository = $this->diContainer->get(SegmentsRepository::class);
$this->tasksLinks = $this->diContainer->get(TasksLinks::class); $this->tasksLinks = $this->diContainer->get(TasksLinks::class);
$this->scheduledTasksRepository = $this->diContainer->get(ScheduledTasksRepository::class); $this->scheduledTasksRepository = $this->diContainer->get(ScheduledTasksRepository::class);
@@ -156,7 +164,7 @@ class SendingQueueTest extends \MailPoetTest {
$this->subscriber->getId(), $this->subscriber->getId(),
$linkTokens->getToken($this->subscriber), $linkTokens->getToken($this->subscriber),
$this->queue->id, $this->queue->id,
$this->newsletterLink->hash, $this->newsletterLink->getHash(),
false false
); );
return Router::buildRequest( return Router::buildRequest(