Skip to content

Commit 6cdbdb1

Browse files
committed
feature #50200 [Mailer] Adds assertEmailSubjectContains and assertEmailSubjectNotContains methods (johanadivare)
This PR was merged into the 6.4 branch. Discussion ---------- [Mailer] Adds `assertEmailSubjectContains` and `assertEmailSubjectNotContains` methods > Adds assertEmailSubjectContains and assertEmailSubjectNotContains | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | No | New feature? | yes | Deprecations? | No | Tickets | Fix #49939 | License | MIT | Doc PR | symfony/symfony-docs#18269 <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> Commits ------- 55ba7b8f22 [Mailer] Add EmailSubjectContains constraint (#49939)
2 parents 3e2fbd4 + 32c5da4 commit 6cdbdb1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Test/MailerAssertionsTrait.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ public static function assertEmailAddressContains(RawMessage $email, string $hea
9090
self::assertThat($email, new MimeConstraint\EmailAddressContains($headerName, $expectedValue), $message);
9191
}
9292

93+
public static function assertEmailSubjectContains(RawMessage $email, string $expectedValue, string $message = ''): void
94+
{
95+
self::assertThat($email, new MimeConstraint\EmailSubjectContains($expectedValue), $message);
96+
}
97+
98+
public static function assertEmailSubjectNotContains(RawMessage $email, string $expectedValue, string $message = ''): void
99+
{
100+
self::assertThat($email, new LogicalNot(new MimeConstraint\EmailSubjectContains($expectedValue)), $message);
101+
}
102+
93103
/**
94104
* @return MessageEvent[]
95105
*/

Tests/Functional/MailerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public function testMailerAssertions()
104104
$this->assertEmailAttachmentCount($email, 1);
105105

106106
$email = $this->getMailerMessage($second);
107+
$this->assertEmailSubjectContains($email, 'Foo');
108+
$this->assertEmailSubjectNotContains($email, 'Bar');
107109
$this->assertEmailAddressContains($email, 'To', '[email protected]');
108110
$this->assertEmailAddressContains($email, 'To', '[email protected]');
109111
$this->assertEmailAddressContains($email, 'Reply-To', '[email protected]');

0 commit comments

Comments
 (0)