mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
NotificationMailer: add tests when user does not have any email
This commit is contained in:
parent
b4f8c7d261
commit
e7a9b10d0d
@ -62,6 +62,46 @@ class NotificationMailerTest extends TestCase
|
|||||||
$mailer->postPersistComment($comment, new PostPersistEventArgs($comment, $objectManager->reveal()));
|
$mailer->postPersistComment($comment, new PostPersistEventArgs($comment, $objectManager->reveal()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPostPersistCommentDestWithNullEmail(): void
|
||||||
|
{
|
||||||
|
$this->expectNotToPerformAssertions();
|
||||||
|
$user1 = (new User())->setEmail('user1@foo.com');
|
||||||
|
$user2 = (new User())->setEmail('user2@foo.com');
|
||||||
|
$user3 = (new User())->setEmail(null);
|
||||||
|
|
||||||
|
$notification = new Notification();
|
||||||
|
$notification
|
||||||
|
->setTitle('test notification')
|
||||||
|
->setSender($user1)
|
||||||
|
->addAddressee($user2)
|
||||||
|
->addAddressee($user3)
|
||||||
|
;
|
||||||
|
|
||||||
|
$comment = (new NotificationComment())
|
||||||
|
->setContent("foo bar baz")
|
||||||
|
->setCreatedBy($user2)
|
||||||
|
;
|
||||||
|
$notification->addComment($comment);
|
||||||
|
|
||||||
|
$mailer = $this->prophesize(MailerInterface::class);
|
||||||
|
|
||||||
|
// a mail only to user1 and user3 should have been sent
|
||||||
|
$mailer->send(Argument::that(function (Email $email) {
|
||||||
|
foreach ($email->getTo() as $address) {
|
||||||
|
if ($address->getAddress() === 'user1@foo.com') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
|
||||||
|
$objectManager = $this->prophesize(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$mailer = $this->buildNotificationMailer($mailer->reveal());
|
||||||
|
$mailer->postPersistComment($comment, new PostPersistEventArgs($comment, $objectManager->reveal()));
|
||||||
|
}
|
||||||
|
|
||||||
private function buildNotificationMailer(
|
private function buildNotificationMailer(
|
||||||
MailerInterface $mailer = null,
|
MailerInterface $mailer = null,
|
||||||
): NotificationMailer
|
): NotificationMailer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user