This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

chrisiek
chrisiek

Mail templates should be registered in Plugin.php when used in Octobercms but during the tests the environment is different.

How to register mail templates and send emails during the phpunit tests?

abwebdevelopers
abwebdevelopers

That's a great question. Love seeing support articles 2 years old with no solution, a lot of views (1682), especially when the documentation is seriously lacking in this area.

It seems like Plugin::registerMailTemplates() is never called when the system is loaded via phpunit which is causing major problems for my once-working unit tests that tested things like "it uses the correct template".

Would love to hear any solutions if anyone. If I figure it out I'll let post it here so at least someone might benefit.


Edit: I have tried running:

\System\Classes\MailManager::instance()->registerCallback(function ($manager) {
    $manager->registerMailTemplates([
        'abwebdevelopers.forms::mail.autoreply',
        'abwebdevelopers.forms::mail.notification',
    ]);
});

but it didn't work

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.