-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'PPF-57/sent-reminder-email' into PPF-53/extra-mails
- Loading branch information
Showing
12 changed files
with
111 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Mails\MailJet; | ||
|
||
use Symfony\Component\Mime\Address; | ||
|
||
final readonly class SandboxMode | ||
{ | ||
public function __construct(private bool $sandboxMode, private array $allowedDomains) | ||
{ | ||
} | ||
|
||
public function forAddress(Address $address): bool | ||
{ | ||
if (!$this->sandboxMode) { | ||
return false; | ||
} | ||
|
||
foreach ($this->allowedDomains as $domain) { | ||
if (str_ends_with($address->getAddress(), $domain)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Mails\MailJet; | ||
|
||
use App\Mails\MailJet\SandboxMode; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mime\Address; | ||
|
||
final class SandboxModeTest extends TestCase | ||
{ | ||
#[DataProvider('sandboxModeProvider')] | ||
public function test_get_sandbox_mode(bool $sandboxMode, array $allowedDomains, Address $to, bool $expected): void | ||
{ | ||
$this->assertSame( | ||
$expected, | ||
(new SandboxMode($sandboxMode, $allowedDomains))->forAddress($to) | ||
); | ||
} | ||
|
||
public static function sandboxModeProvider(): array | ||
{ | ||
$allowedDomains = ['publiq.be', '[email protected]']; | ||
|
||
return [ | ||
'Sandbox mode is off and domain is not allowed, should return false' => [ | ||
false, | ||
$allowedDomains, | ||
new Address('[email protected]'), | ||
false, | ||
], | ||
'Sandbox mode is off and domain is allowed, should return false' => [ | ||
false, | ||
$allowedDomains, | ||
new Address('[email protected]'), | ||
false, | ||
], | ||
'Sandbox mode is on, but domain is allowed, should return false' => [ | ||
true, | ||
$allowedDomains, | ||
new Address('[email protected]'), | ||
false, | ||
], | ||
'Sandbox mode is on, and domain is not allowed, should return true' => [ | ||
true, | ||
$allowedDomains, | ||
new Address('[email protected]'), | ||
true, | ||
], | ||
'Sandbox mode is on, entire email matches, should return false' => [ | ||
true, | ||
$allowedDomains, | ||
new Address('[email protected]'), | ||
false, | ||
], | ||
]; | ||
} | ||
} |