Question

I am trying to write automated tests for a or that will sent an email on submission.
I can write the test to check for the presence of the entity that is created along side the email, but I also want to have my automated test check that the system is sending an email too.

The examples I can find seem to relate to Laravel and the use of spies to see if a particular class method is called, however I can't find any examples of how to do that in Drupal 8 and in my particular use case I am using the function _user_mail_notify() and not a class method.

Does anyone have an example of testing that emails have seen sent at all?

Was it helpful?

Solution

Look at core tests that utilize email. For example:

The tests demonstrate ways to inspect the plugin.manager.mail service for signs that mail was successfully sent.

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top