-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Introduces an InMemoryTransport to save messages in memory. #32409
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
787a563
to
839af20
Compare
839af20
to
1d5c7ab
Compare
Please update your PR according to changes introduced in #31946 |
fabpot
added a commit
that referenced
this pull request
Aug 4, 2019
This PR was merged into the 4.4 branch. Discussion ---------- [Mailer] Add message events logger | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | refs #31592, refs #32409, refs #31947, refs #31747 | License | MIT | Doc PR | n/a To allow testing emails and for the web profiler, we need a way to store all sent/queued messages. Commits ------- 7642178 [Mailer] added message events logger
I think that testing emails is orthogonal to the transport. See #32930 for an implementation that allows to receive the email AND test it at the same time in functional tests. |
fabpot
added a commit
that referenced
this pull request
Aug 5, 2019
…for the Mailer (fabpot) This PR was merged into the 4.4 branch. Discussion ---------- [Mailer][Mime] Add PHPUnit constraints and assertions for the Mailer | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | refs #31592, closes #32409, closes #31947, closes #31747, closes #30850 | License | MIT | Doc PR | n/a This PR introduces PHPUnit constraints and assertions to ease testing emails in functional tests: ```php <?php namespace App\Tests; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class MailerAssertionsTraitsTest extends WebTestCase { public function testSomething() { $client = static::createClient(); $client->request('GET', '/'); $this->assertEmailCount(2); $this->assertEmailIsQueued($this->getMailerEvent(0)); $email = $this->getMailerMessage(0); $this->assertEmailHasHeader($email, 'To'); $this->assertEmailHeaderSame($email, 'To', 'fabien@symfony.com'); $this->assertEmailTextBodyContains($email, 'Bar'); $this->assertEmailHtmlBodyContains($email, 'Foo'); $this->assertEmailAttachementCount($email, 1); } } ``` Commits ------- 23f237b added PHPUnit constraints and assertions for the Mailer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR provides an in-memory transport to save sent messages in memory.
To use this transport you need to configure your mailer with this DSN:
in-memory://
# .env.local .env.test MAILER_DSN=in-memory://
Now you can retrieve the
mailer.default_transport
which is of typeInMemoryTransport
and can get the sent messages via calling the get() method.