Codeception / module-yii2

Codeception module for Yii2 framework
MIT License
16 stars 36 forks source link

Testing with multiple mailer instances #76

Closed Swanty closed 1 year ago

Swanty commented 1 year ago

Hi, we have project with a global mailer (for system messages) and then for each client we build a new mailer instance depending on their mail settings

How to test multiple mailer instances by using seeEmailIsSent and grabLastSentEmail functions?
Based on #31 it seems not possible?

Currently we mock \yii\symfonymailer\Mailer::class to save messages for testing, but would be much nicer if we could use the built-in functions :pray:

SamMousa commented 1 year ago

The built in functions only work for the primary component. Making it work for all Mailer components would require changing the api since you would need to tell which component did the sending.

You could create your own helper functions to work with other Mailer instances. I'm not sure this use case belongs in the built in functions.

Swanty commented 1 year ago

Makes sense, thank you :bow: