|
@@ -143,6 +143,56 @@ class MailerTest extends TestCase
|
|
|
$this->assertInstanceOf(Email::class, $emailsCollection->first());
|
|
$this->assertInstanceOf(Email::class, $emailsCollection->first());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @see Mailer::main()
|
|
|
|
|
+ */
|
|
|
|
|
+ public function testMainWithReport()
|
|
|
|
|
+ {
|
|
|
|
|
+ $mailer = $this->makeMailerMock('main');
|
|
|
|
|
+ $mailerModel = $this->getMockBuilder(MailerModelInterface::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
+ $builderService = $this->getMockBuilder(BuilderInterface::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
+
|
|
|
|
|
+ $email = $this->getMockBuilder(Email::class)->disableOriginalConstructor()->getMock();
|
|
|
|
|
+ $email->method('getEmailRecipients')->willReturn(new ArrayCollection());
|
|
|
|
|
+ $email->method('getEmailEntity')->willReturn(new \App\Entity\Message\Email());
|
|
|
|
|
+
|
|
|
|
|
+ $emailsCollection = new ArrayCollection([$email]);
|
|
|
|
|
+
|
|
|
|
|
+ $this->builderIterator
|
|
|
|
|
+ ->method('getBuilderFor')
|
|
|
|
|
+ ->willReturn($builderService);
|
|
|
|
|
+
|
|
|
|
|
+ $builderService
|
|
|
|
|
+ ->method('build')
|
|
|
|
|
+ ->with($mailerModel)
|
|
|
|
|
+ ->willReturn($emailsCollection)
|
|
|
|
|
+ ;
|
|
|
|
|
+
|
|
|
|
|
+ $mailer
|
|
|
|
|
+ ->method('reduceEmailsCollectionInPreproduction')
|
|
|
|
|
+ ->with($emailsCollection)
|
|
|
|
|
+ ->willReturn($emailsCollection)
|
|
|
|
|
+ ;
|
|
|
|
|
+
|
|
|
|
|
+ $mailerModel->method('getSendReport')->willReturn(true);
|
|
|
|
|
+
|
|
|
|
|
+ $mailer
|
|
|
|
|
+ ->expects(self::once())
|
|
|
|
|
+ ->method('sendReport')
|
|
|
|
|
+ ;
|
|
|
|
|
+
|
|
|
|
|
+ $this->entityManager
|
|
|
|
|
+ ->expects(self::once())
|
|
|
|
|
+ ->method('flush')
|
|
|
|
|
+ ;
|
|
|
|
|
+
|
|
|
|
|
+ $emailsCollection = $mailer->main($mailerModel);
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertEquals(MessageStatusEnum::NO_RECIPIENT, $email->getEmailEntity()->getStatus());
|
|
|
|
|
+
|
|
|
|
|
+ $this->assertInstanceOf(Email::class, $emailsCollection->first());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @see Mailer::send()
|
|
* @see Mailer::send()
|
|
|
*/
|
|
*/
|