Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Mailer] AddassertEmailAddressNotContains#60740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@santysisi
Copy link
Contributor

@santysisisantysisi commentedJun 7, 2025
edited
Loading

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
IssuesNo
LicenseMIT

This PR introduces a new assertion methodassertEmailAddressNotContains() to theMailerAssertionsTrait.

The new method complements the existingassertEmailAddressContains() by allowing developers to assert that a specific email addressdoes not appear in a given header. This addition brings theassertEmailAddressContains in line with other similar assertion pairs already available in the trait, such as:

  • assertEmailTextBodyContains /assertEmailTextBodyNotContains
  • assertEmailHtmlBodyContains /assertEmailHtmlBodyNotContains
  • assertEmailSubjectContains /assertEmailSubjectNotContains

Example usage

$this->assertEmailAddressNotContains($email,'To','test@test.com');


7.4
---
* added`assertEmailAddressNotContains()` to`MailerAssertionsTrait`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggested change
* added`assertEmailAddressNotContains()` to`MailerAssertionsTrait`.
* Add`assertEmailAddressNotContains()` to the`MailerAssertionsTrait`

santysisi reacted with heart emojisantysisi reacted with rocket emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I agree with your suggestion, and I've made that change.
Thanks a lot for your help!

bkosun reacted with thumbs up emoji
Comment on lines 109 to 111
$this->assertEmailAddressNotContains($email,'To','fabien@fake.symfony.com');
$this->assertEmailAddressNotContains($email,'To','thomas@fake.symfony.com');
$this->assertEmailAddressNotContains($email,'Reply-To','me@fake.symfony.com');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It seems that these assertions are redundant, given that the addresses specified have never been used before.

santysisi reacted with heart emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I don’t think the assertions are an issue, but I’m happy to update the emails if you have any suggestions for alternatives.
Thanks again! 😄❤️

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I've updated the emails tohelene@symfony.com. I believe this still tests the same behavior, but this format is more in line with the emails currently used in Symfony tests 😊

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A test that cannot fail is not useful. I think you should to add assertions that would actually fail if something breaks.

santysisi reacted with heart emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd like to clarify a couple of points:

  1. The method is simply applying aLogicalNot to an existingConstraint that is already implemented and tested.
  2. If you look at several of the current assertions in the sametest file, you'll notice that they cover similar cases to the ones I'm adding now. In fact, the sameemail is already being tested, just in a different way.

As always, if you have any suggestions, they're more than welcome! 😄

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hi@Spomky@bkosun 👋, I also added this assertion

$this->assertEmailAddressNotContains($email,'To','thomas@symfony.com');

This checks that the first email does not includethomas@symfony.com in the "To" field.

Just to clarify: this address is included in the second email, but not in the first one, which is the behavior this assertion is verifying.

bkosun reacted with thumbs up emoji

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Now it makes sense. Thank you!

santysisi reacted with heart emoji
@santysisisantysisiforce-pushed thefeature/add-assertEmailAddressNotContains branch fromb64a567 to559d45bCompareJune 8, 2025 05:01
@Spomky
Copy link
Contributor

Hi@santysisi,

Indeed this could be a nice addition.
❓ Question: What about helper methods such asassertToEmailAddressNotContains/assertReplyToEmailAddressNotContains? I knowassertToEmailAddressContains/assertReplyToEmailAddressContains do not exist. Could be added too. WDYT?

santysisi reacted with heart emoji

@santysisi
Copy link
ContributorAuthor

Hi@Spomky 👋, thanks a lot for your comment! 😊

I see where you're coming from. The main concern with that approach is that it could lead to a large number of helper methods, likeassertBccEmailAddressContains,assertCcEmailAddressContains,assertFromEmailAddressContains, and so on. Personally, I prefer having a single method that accepts aheaderName argument, it's more flexible (IMO) and avoids code duplication.

That said, if you and others feel that having separate, explicit methods is more readable or convenient, I'm happy to add them! 😄

Thanks again for your feedback ❤️

@Spomky
Copy link
Contributor

OK so let consider the suggested change from@bkosun and I'll approve this PR.

bkosun reacted with thumbs up emojisantysisi reacted with heart emojisantysisi reacted with rocket emoji

@santysisisantysisiforce-pushed thefeature/add-assertEmailAddressNotContains branch 3 times, most recently from10566de toce99b79CompareJune 11, 2025 22:08
@santysisisantysisiforce-pushed thefeature/add-assertEmailAddressNotContains branch fromce99b79 to9cc6a63CompareJune 11, 2025 22:09
@nicolas-grekas
Copy link
Member

Thank you@santysisi.

santysisi reacted with heart emojisantysisi reacted with rocket emoji

@nicolas-grekasnicolas-grekas merged commitc9500d8 intosymfony:7.4Jun 16, 2025
11 checks passed
This was referencedOct 27, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@SpomkySpomkySpomky approved these changes

+1 more reviewer

@bkosunbkosunbkosun approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

5 participants

@santysisi@Spomky@nicolas-grekas@bkosun@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp