Add subject for participant mail

This commit is contained in:
philipp lang 2024-03-15 01:11:22 +01:00
parent 6f03063cba
commit 91943a6321
3 changed files with 6 additions and 4 deletions

View File

@ -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,
);
}

View File

@ -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));
}
}

View File

@ -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