8000 Failing test async emails with templates · symfony/symfony@fa6e8e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit fa6e8e7

Browse files
committed
Failing test async emails with templates
1 parent b47b239 commit fa6e8e7

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/EmailController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;
1313

14+
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
1415
use Symfony\Component\HttpFoundation\Response;
1516
use Symfony\Component\Mailer\MailerInterface;
1617
use Symfony\Component\Mime\Address;
@@ -38,4 +39,16 @@ public function indexAction(MailerInterface $mailer)
3839

3940
return new Response();
4041
}
42+
43+
public function sendTemplatedEmail(MailerInterface $mailer)
44+
{
45+
$mail = (new TemplatedEmail())
46+
->to('fabien@symfony.com')->from('fabien@symfony.com')->subject('Foo')
47+
->addReplyTo('me@symfony.com')
48+
->htmlTemplate('mail.html.twig');
49+
50+
$mailer->send($mail);
51+
52+
return new Response();
53+
}
4154
}

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ array_controller:
6060
send_email:
6161
path: /send_email
6262
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\EmailController::indexAction }
63+
64+
send_templated_email:
65+
path: /send_templated_email
66+
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\EmailController::sendTemplatedEmail }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Test!

src/Symfony/Bundle/FrameworkBundle/Tests/Functional/MailerTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,11 @@ public function testMailerAssertions()
9999
$this->assertEmailAddressContains($email, 'To', 'thomas@symfony.com');
100100
$this->assertEmailAddressContains($email, 'Reply-To', 'me@symfony.com');
101101
}
102+
103+
public function testSendingQueuedMessage()
104+
{
105+
$client = $this->createClient(['test_case' => 'Mailer', 'root_config' => 'config_messenger.yml', 'debug' => true]);
106+
$client->request('GET', '/send_templated_email');
107+
$this->assertResponseIsSuccessful();
108+
}
102109
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
imports:
2+
- { resource: ../config/default.yml }
3+
- { resource: services.yml }
4+
5+
framework:
6+
mailer:
7+
dsn: 'null://null'
8+
envelope:
9+
sender: sender@example.org
10+
recipients:
11+
- redirected@example.org
12+
profiler: ~
13+
14+
messenger:
15+
transports:
16+
default: 'logger://'
17+
18+
routing:
19+
Symfony\Component\Mailer\Messenger\SendEmailMessage: default
20+

0 commit comments

Comments
 (0)
0