Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add FakeMailer inspired by Laravel #525

Closed
wants to merge 1 commit into from

Conversation

simonschaufi
Copy link
Contributor

See https://laravel.com/docs/10.x/mail#testing-mailable-sending for inspiration source and https://github.com/laravel/framework/blob/10.x/src/Illuminate/Support/Testing/Fakes/MailFake.php for the original source code.

How to use:

$mailer = GeneralUtility::makeInstance(FakeMailer::class);
GeneralUtility::setSingletonInstance(Mailer::class, $mailer);

// run code which should send an email (dispatch controller)

$mailer->assertSent(FluidEmail::class, 1);
$mailer->assertSent(FluidEmail::class, function (FluidEmail $mail) {
    $textBody = $mail->getTextBody();

    return $mail->getSubject() === 'Subject'
        && str_contains($textBody, 'First name: Anna')
        && in_array(new Address('[email protected]', 'My Company'), $mail->getFrom(), false);
});

@lolli42
Copy link
Member

lolli42 commented Oct 8, 2024

Hey.

We decided to not implement this, for similar reasons as with #524

Additionally, this creates quite a dependency to core class Mailer, which would have to be maintained in the future.

I hope it is ok to close here for now.

@lolli42 lolli42 closed this Oct 8, 2024
@simonschaufi simonschaufi deleted the FakeMailer branch October 8, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants