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] Fix forgetMailers with MailFake #40495

Merged
merged 2 commits into from
Jan 20, 2022
Merged

[8.x] Fix forgetMailers with MailFake #40495

merged 2 commits into from
Jan 20, 2022

Conversation

reindert-vetter
Copy link
Contributor

@reindert-vetter reindert-vetter commented Jan 19, 2022

I use \Illuminate\Support\Facades\Mail::forgetMailers() to force a new mailer to be used. But I can't use that because my test will fail. That's because that method doesn't exist in \Illuminate\Support\Testing\Fakes\MailFake. It makes sense that \Illuminate\Support\Testing\Fakes\MailFake also has that method.

Error:

Error : Call to undefined method \Illuminate\Support\Testing\Fakes\MailFake::forgetMailers()
 (...)/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261

Workaround:

        $facadeRoot = Mail::getFacadeRoot();
        if (method_exists($facadeRoot, 'forgetMailers')) {
            Mail::forgetMailers();
        }

I use `\Illuminate\Support\Facades\Mail::forgetMailers()` to force a new mailer to be used. But I can't use that because my test will fail. That's because that method doesn't exist in `\Illuminate\Support\Testing\Fakes\MailFake`. It makes sense that `\Illuminate\Support\Testing\Fakes\MailFake` also has that method.

Error : Call to undefined method \Illuminate\Support\Testing\Fakes\MailFake::forgetMailers()
 (...)/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:261

_____

Workaround:
```php
        $facadeRoot = Mail::getFacadeRoot();
        if (method_exists($facadeRoot, 'forgetMailers')) {
            Mail::forgetMailers();
        }
```
@reindert-vetter reindert-vetter changed the title Fix forgetMailers with MailFake [8.x] Fix forgetMailers with MailFake Jan 19, 2022
@taylorotwell taylorotwell merged commit c855979 into laravel:8.x Jan 20, 2022
@reindert-vetter reindert-vetter deleted the patch-3 branch January 20, 2022 15:42
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