email contains address - behat
silverbackdan opened this issue · 1 comments
In the related code above, when checking an email address, it would be nice to check the name and email address or have the error response consistent.
If I check the email is Name <email@address.com>
- the test fails, but the error message says the field is exactly as expected. This is because in the output the call to display the value is $email->getHeaders()->get($headerName)->getBodyAsString()
- perhaps it is worth checking against this normalized value in the main checks themselves?
I'm not sure about changing this line here:
As you're in beta, this is breaking - so perhaps expanding the check to make it pass if the normalized string is equal to the expected string as well?
Open for discussion.
Hi, and sorry for the late reply!
Assertions from SymfonyMailerAssertionsTrait.php
are the same assertions from Symfony https://github.com/symfony/symfony/blob/5.4/src/Symfony/Bundle/FrameworkBundle/Test/MailerAssertionsTrait.php and I don't want have a different logic between my assertions and Symfony's assertions.
However I think you are right about $expectedValue === $address->getAddress()
and $email->getHeaders()->get($headerName)->getBodyAsString()
, so you can open a bug issue on Symfony repository.
Also, I'm planning to find a way to drop SymfonyMailerAssertionsTrait.php
and use assertions from https://github.com/symfony/symfony/blob/5.4/src/Symfony/Bundle/FrameworkBundle/Test/MailerAssertionsTrait.php, this way it will ease the maintenance. EDIT: implemented in #24