Skip to content

Mailer and Mime assertion trait cannot handle encrypted emails #233

@krrico

Description

@krrico

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 =)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions