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

[8.x] Prevent $mailer being reset when testing mailables that implement ShouldQueue #42695

Merged
merged 1 commit into from
Jun 7, 2022
Merged

Conversation

JayBizzle
Copy link
Contributor

class Signup extends Mailable implements ShouldQueue
{
    // snip
}
Mail::mailer('mail-connection')
    ->to('[email protected]')
    ->send(new Signup());
public function send_signup_using_correct_mailer()
{
    Mail::fake();

    // snip

    Mail::assertQueued(Signup::class, function ($mail) {
        return $mail->mailer == 'mail-connection'; // FAILS: It is actually NULL
    });
}

When calling send(), the $mailer is set on the Mailable instance, then immediately reset to null on the MailFake (which it should do).

The problem occurs when the Mailable implements ShouldQueue. After the $mailer property has been reset, the queue() method then sets the $mailer again on the Mailable, but this time it is now NULL.

This change fixes that.

@JayBizzle JayBizzle changed the title [8.x] Prevent $mailer being reset when testing mailables that implement ShouldQueue [8.x] Prevent $mailer being reset when testing mailables that implement ShouldQueue Jun 7, 2022
@taylorotwell taylorotwell merged commit 065e4b8 into laravel:8.x Jun 7, 2022
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.

3 participants