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] 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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

@jschaedl
Copy link
Contributor

QA
Branch?4.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#31747
LicenseMIT
Doc PRN/A

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.testMAILER_DSN=in-memory://

Now you can retrieve themailer.default_transport which is of typeInMemoryTransport and can get the sent messages via calling the get() method.

class DefaultControllerTestextends WebTestCase{publicfunctiontestSomething()    {$client =static::createClient();// ...$this->assertSame(200,$client->getResponse()->getStatusCode());/* @var InMemoryTransport $transport */$transport =self::$container->get('mailer.default_transport');$this->assertCount(1,$transport->get());    }}

@jschaedljschaedlforce-pushed themailer-inmemory_transport branch from787a563 to839af20CompareJuly 6, 2019 14:46
@jschaedljschaedl marked this pull request as ready for reviewJuly 6, 2019 15:43
@jschaedljschaedlforce-pushed themailer-inmemory_transport branch from839af20 to1d5c7abCompareJuly 6, 2019 16:26
@nicolas-grekasnicolas-grekas added this to thenext milestoneJul 8, 2019
@fabpotfabpot added the Mailer labelJul 8, 2019
@Koc
Copy link
Contributor

Koc commentedJul 21, 2019

Please update your PR according to changes introduced in#31946

fabpot added a commit that referenced this pull requestAug 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     <!-- seehttps://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/aTo 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
@fabpot
Copy link
Member

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.

@fabpotfabpot closed thisAug 4, 2019
fabpot added a commit that referenced this pull requestAug 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     <!-- seehttps://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/aThis PR introduces PHPUnit constraints and assertions to ease testing emails in functional tests:```php<?phpnamespace 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
@nicolas-grekasnicolas-grekas modified the milestones:next,4.4Oct 27, 2019
@jschaedljschaedl deleted the mailer-inmemory_transport branchFebruary 23, 2020 08:01
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

5 participants

@jschaedl@Koc@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp