Heyho,
while writing some functional tests for sending encrypted and signed emails in our application I saw that the MailerAssertionsTrait and the MimeAssertionTrait are using Symfony's Email class rather than the parent Message or even RawMessage classes.
Symfony also provides a MailerAssertionsTrait in the Framework Bundle which uses RawMessage everywhere.
The issue now is the following:
Symfony's SMimeEncrypter class does not return an Email object but a Message object instead when used like documented.
Codeception's MailerAssertionsTrait::grabLastSentEmail has ?Email as return type which will cause a type error here since the MessageEvent fetched from Symfony's MessageLoggerListener contains a Message Object and not an object of its child class Email.
I already prepared a fix for this here:
#232
There's just the question whether to use RawMessage as type hint everywhere, like Symfony does in its own MailerAssertionsTrait or whether to use the "biggest" supported type for each of the Mime Constraints used (e.g. Message for EmailHasHeader constrait, as it does not support RawMessage) like I did in my current fix.
I already prepared the tests in the symfony-module-tests repo here: Codeception/symfony-module-tests#40
Thanks for help and your great work =)
Heyho,
while writing some functional tests for sending encrypted and signed emails in our application I saw that the MailerAssertionsTrait and the MimeAssertionTrait are using Symfony's Email class rather than the parent Message or even RawMessage classes.
Symfony also provides a MailerAssertionsTrait in the Framework Bundle which uses RawMessage everywhere.
The issue now is the following:
Symfony's SMimeEncrypter class does not return an Email object but a Message object instead when used like documented.
Codeception's MailerAssertionsTrait::grabLastSentEmail has
?Emailas return type which will cause a type error here since the MessageEvent fetched from Symfony's MessageLoggerListener contains aMessageObject and not an object of its child classEmail.I already prepared a fix for this here:
#232
There's just the question whether to use
RawMessageas type hint everywhere, like Symfony does in its own MailerAssertionsTrait or whether to use the "biggest" supported type for each of the Mime Constraints used (e.g.Messagefor EmailHasHeader constrait, as it does not supportRawMessage) like I did in my current fix.I already prepared the tests in the symfony-module-tests repo here: Codeception/symfony-module-tests#40
Thanks for help and your great work =)