/**
  * @return string
  */
 public function createQueueAction()
 {
     $readyMessages = $this->messageRepository->getReadyToBeQueued();
     foreach ($readyMessages as $message) {
         $queueCount = $this->queueItemRepository->queueMessage($message);
         if ($this->isVerbose()) {
             $this->logger->info('Message to be queued: ' . $this->messageToString($message, $queueCount));
         }
     }
     if ($this->hasCacheStorage()) {
         $this->cacheStorage->setItem(\DmMailer\View\DataProvider\Kpi::CS_LAST_QUEUE_CREATION, $this->getTime());
     }
     return '';
 }
Esempio n. 2
0
 /**
  * @covers DmMailer\Repository\QueueItem
  */
 public function testQueueMessage()
 {
     $oldQueueSize = count($this->sut->findAll());
     $campaign = $this->campaignRepo->findOneBy(['entityId' => 1]);
     $message = $this->messageRepo->getNewEntity();
     $message->setSubject('Subject');
     $message->setBody('Body');
     $message->setCampaign($campaign);
     $this->sut->queueMessage($message);
     $newQueueSize = count($this->sut->findAll());
     $this->assertGreaterThan($oldQueueSize, $newQueueSize);
     $this->assertEquals($oldQueueSize + count($campaign->getSubscribers()), $newQueueSize);
 }