diff --git a/app/Form/Mails/ConfirmRegistrationMail.php b/app/Form/Mails/ConfirmRegistrationMail.php index d7ea99b7..389c9727 100644 --- a/app/Form/Mails/ConfirmRegistrationMail.php +++ b/app/Form/Mails/ConfirmRegistrationMail.php @@ -18,7 +18,7 @@ class ConfirmRegistrationMail extends Mailable * * @return void */ - public function __construct() + public function __construct(public Participant $participant) { // } @@ -31,7 +31,7 @@ class ConfirmRegistrationMail extends Mailable public function envelope() { return new Envelope( - subject: 'Confirm Registration Mail', + subject: 'Deine Anmeldung zu ' . $this->participant->form->name, ); } diff --git a/app/Form/Models/Participant.php b/app/Form/Models/Participant.php index 3441c31a..39869826 100644 --- a/app/Form/Models/Participant.php +++ b/app/Form/Models/Participant.php @@ -58,6 +58,6 @@ class Participant extends Model return; } - Mail::to($this->getFields()->getMailRecipient())->queue(new ConfirmRegistrationMail()); + Mail::to($this->getFields()->getMailRecipient())->queue(new ConfirmRegistrationMail($this)); } } diff --git a/tests/Feature/Form/FormRegisterActionTest.php b/tests/Feature/Form/FormRegisterActionTest.php index 89f65caa..cef59736 100644 --- a/tests/Feature/Form/FormRegisterActionTest.php +++ b/tests/Feature/Form/FormRegisterActionTest.php @@ -6,6 +6,7 @@ use App\Form\Enums\NamiType; use App\Form\Enums\SpecialType; use App\Form\Mails\ConfirmRegistrationMail; use App\Form\Models\Form; +use App\Form\Models\Participant; use App\Group; use App\Group\Enums\Level; use App\Member\Member; @@ -62,12 +63,13 @@ class FormRegisterActionTest extends FormTestCase $this->textField('email')->specialType(SpecialType::EMAIL), ]), ]) + ->name('Ver2') ->create(); $this->register($form, ['vorname' => 'Lala', 'nachname' => 'GG', 'email' => 'example@test.test']) ->assertOk(); - Mail::assertQueued(ConfirmRegistrationMail::class, fn ($message) => $message->hasTo('example@test.test', 'Lala GG')); + Mail::assertQueued(ConfirmRegistrationMail::class, fn ($message) => $message->hasTo('example@test.test', 'Lala GG') && $message->hasSubject('Deine Anmeldung zu Ver2')); } public function testItDoesntSendEmailWhenNoMailFieldGiven(): void