From 59920bac1d3a4f417734eed1139074de2ed408b0 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Mon, 10 Jul 2023 10:31:56 +0200 Subject: [PATCH] Fix local maildispatcher casing --- app/Maildispatcher/Data/MailEntry.php | 1 + tests/Feature/Maildispatcher/StoreTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/Maildispatcher/Data/MailEntry.php b/app/Maildispatcher/Data/MailEntry.php index b93d9777..e54c7a3d 100644 --- a/app/Maildispatcher/Data/MailEntry.php +++ b/app/Maildispatcher/Data/MailEntry.php @@ -8,5 +8,6 @@ class MailEntry extends Data { public function __construct(public string $email) { + $this->email = strtolower($email); } } diff --git a/tests/Feature/Maildispatcher/StoreTest.php b/tests/Feature/Maildispatcher/StoreTest.php index 6fdd1ebe..47b850be 100644 --- a/tests/Feature/Maildispatcher/StoreTest.php +++ b/tests/Feature/Maildispatcher/StoreTest.php @@ -3,6 +3,7 @@ namespace Tests\Feature\Maildispatcher; use App\Activity; +use App\Maildispatcher\Models\Localmaildispatcher; use App\Maildispatcher\Models\Maildispatcher; use App\Mailgateway\Models\Mailgateway; use App\Mailgateway\Types\LocalType; @@ -48,4 +49,18 @@ class StoreTest extends TestCase 'to' => 'jane@example.com', ]); } + + public function testMaildispatcherReceivesLowerVersionOfEmail(): void + { + $gateway = Mailgateway::factory()->type(LocalType::class, [])->create(); + Member::factory()->defaults()->create(['email' => 'Jane@example.com']); + + $this->postJson('/maildispatcher', [ + 'name' => 'test', + 'gateway_id' => $gateway->id, + 'filter' => [], + ]); + + $this->assertEquals('jane@example.com', Localmaildispatcher::first()->to); + } }