Skip to content

Commit

Permalink
Merge branch 'PPF-56/activate-mail' into PPF-55/blocked-mail
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Eelen committed Aug 20, 2024
2 parents c292e20 + 226d543 commit 38f728f
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions tests/Mails/MailManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,29 +104,37 @@ public function testSendMail(
string $subject,
array $expectedParameters
): void {
$counter = 0;

$this->mailer
->expects($this->once())
->expects($this->exactly(count($this->contacts)))
->method('send')
->with(
new Address(config('mail.from.address'), config('mail.from.name')),
$this->callback(function (Addresses $addresses) {
foreach ($addresses as $i => $address) {
if ($address->getAddress() !== $this->contacts[$i]->email) {
return false;
}

if ($address->getName() !== $this->contacts[$i]->firstName . ' ' . $this->contacts[$i]->lastName) {
return false;
}
$this->callback(function (Addresses $addresses) use (&$counter) {
/** @var Address $address */
$address = $addresses->first();
if ($address->getAddress() !== $this->contacts[$counter]->email) {
return false;
}

if ($address->getName() !== $this->contacts[$counter]->firstName . ' ' . $this->contacts[$counter]->lastName) {
return false;
}

return true;
}),
$templateId,
$subject,
$this->callback(function ($parameters) use ($expectedParameters) {
$this->callback(function ($parameters) use ($expectedParameters, &$counter) {
$expectedParameters['firstName'] = $this->contacts[$counter]->firstName;
$expectedParameters['lastName'] = $this->contacts[$counter]->lastName;
$expectedParameters['contactType'] = $this->contacts[$counter]->type->value;

$this->assertEquals($expectedParameters, $parameters);

$counter++;

return true;
})
);
Expand All @@ -143,7 +151,9 @@ public static function mailDataProvider(): array
'templateId' => self::TEMPLATE_ACTIVATED_ID,
'subject' => 'Publiq platform - Integration activated',
'expectedParameters' => [
'firstName' => 'Publiq platform',
'firstName' => 'Grote',
'lastName' => 'Smurf',
'contactType' => 'technical',
'url' => 'http://www.example.com//nl/integraties/' . self::INTEGRATION_ID,
'integrationName' => 'Mock Integration',
'type' => 'search-api',
Expand Down

0 comments on commit 38f728f

Please sign in to comment.