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

Error during the mail testing #138

Open
Goodmain opened this issue Aug 5, 2024 · 0 comments
Open

Error during the mail testing #138

Goodmain opened this issue Aug 5, 2024 · 0 comments
Assignees

Comments

@Goodmain
Copy link
Contributor

Goodmain commented Aug 5, 2024

I changed the ForgotPasswordMail structure at the following branch https://github.com/RonasIT/laravel-empty-project/tree/error-when-testing-mail-content and found that if we do not use a viewData it fails tests.

Illuminate\View\ViewException: Undefined variable $hash (View: /app/resources/views/emails/forgot_password.blade.php)
/app/storage/framework/views/ebbd7a56f1475ebab6e4bb80cd203236.php:25
/app/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:60
/app/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php:73
/app/vendor/laravel/framework/src/Illuminate/View/View.php:208
/app/vendor/laravel/framework/src/Illuminate/View/View.php:191
/app/vendor/laravel/framework/src/Illuminate/View/View.php:160
/app/vendor/ronasit/laravel-helpers/src/Traits/MailsMockTrait.php:188
/app/vendor/ronasit/laravel-helpers/src/Traits/MailsMockTrait.php:79
/app/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/MailFake.php:374
/app/vendor/laravel/framework/src/Illuminate/Collections/Arr.php:926
/app/vendor/laravel/framework/src/Illuminate/Collections/Collection.php:369
/app/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/MailFake.php:374
/app/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/MailFake.php:210
/app/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:357
/app/vendor/ronasit/laravel-helpers/src/Traits/MailsMockTrait.php:66
/app/tests/AuthTest.php:259

This row is the reason for error https://github.com/RonasIT/laravel-helpers/blob/master/src/Traits/MailsMockTrait.php#L188

{
        $view = (method_exists($mail, 'content')) ? $mail->content()->view : $mail->view;
        $mailContent = view($view, $mail->viewData)->render();

        if ($exportMode) {
            $this->exportContent($mailContent, $expectedMailData['fixture']);
        }

We support only viewData but a Mailable object may not have any viewData.

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

No branches or pull requests

2 participants