aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/UserBundle/Tests/Mailer
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-01-21 12:27:47 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2016-01-21 12:27:47 +0100
commit9aa66d6244935fe86a5598fbdbe518cf6204af2e (patch)
treea616f79e642b9683b3c7b597ed9c4072c0af5cdf /src/Wallabag/UserBundle/Tests/Mailer
parente72a943ad244f8b6349e31eb9a148808045b224b (diff)
parentabd454c45633e335d9d63bcd250e760b968f8138 (diff)
downloadwallabag-9aa66d6244935fe86a5598fbdbe518cf6204af2e.tar.gz
wallabag-9aa66d6244935fe86a5598fbdbe518cf6204af2e.tar.zst
wallabag-9aa66d6244935fe86a5598fbdbe518cf6204af2e.zip
Merge pull request #1565 from wallabag/v2-2fa-html
Use HTML email for 2FA
Diffstat (limited to 'src/Wallabag/UserBundle/Tests/Mailer')
-rw-r--r--src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php
index 61e960f9..e3f43a7e 100644
--- a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php
+++ b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php
@@ -4,8 +4,6 @@ namespace Wallabag\UserBundle\Tests\Mailer;
4 4
5use Wallabag\UserBundle\Entity\User; 5use Wallabag\UserBundle\Entity\User;
6use Wallabag\UserBundle\Mailer\AuthCodeMailer; 6use Wallabag\UserBundle\Mailer\AuthCodeMailer;
7use Symfony\Component\Translation\Translator;
8use Symfony\Component\Translation\Loader\ArrayLoader;
9 7
10/** 8/**
11 * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ 9 * @see https://www.pmg.com/blog/integration-testing-swift-mailer/
@@ -27,7 +25,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
27{ 25{
28 protected $mailer; 26 protected $mailer;
29 protected $spool; 27 protected $spool;
30 protected $translator; 28 protected $twig;
31 29
32 protected function setUp() 30 protected function setUp()
33 { 31 {
@@ -38,12 +36,13 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
38 ); 36 );
39 $this->mailer = new \Swift_Mailer($transport); 37 $this->mailer = new \Swift_Mailer($transport);
40 38
41 $this->translator = new Translator('en'); 39 $twigTemplate = <<<TWIG
42 $this->translator->addLoader('array', new ArrayLoader()); 40{% block subject %}subject{% endblock %}
43 $this->translator->addResource('array', array( 41{% block body_html %}html body {{ code }}{% endblock %}
44 'auth_code.mailer.subject' => 'auth_code subject', 42{% block body_text %}text body {{ support_url }}{% endblock %}
45 'auth_code.mailer.body' => 'Hi %user%, here is the code: %code% and the support: %support%', 43TWIG;
46 ), 'en', 'wallabag_user'); 44
45 $this->twig = new \Twig_Environment(new \Twig_Loader_Array(array('@WallabagUserBundle/Resources/views/TwoFactor/email_auth_code.html.twig' => $twigTemplate)));
47 } 46 }
48 47
49 public function testSendEmail() 48 public function testSendEmail()
@@ -56,9 +55,10 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
56 55
57 $authCodeMailer = new AuthCodeMailer( 56 $authCodeMailer = new AuthCodeMailer(
58 $this->mailer, 57 $this->mailer,
59 $this->translator, 58 $this->twig,
60 'nobody@test.io', 59 'nobody@test.io',
61 'wallabag test', 60 'wallabag test',
61 'http://0.0.0.0/support',
62 'http://0.0.0.0' 62 'http://0.0.0.0'
63 ); 63 );
64 64
@@ -69,7 +69,8 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase
69 $msg = $this->spool->getMessages()[0]; 69 $msg = $this->spool->getMessages()[0];
70 $this->assertArrayHasKey('test@wallabag.io', $msg->getTo()); 70 $this->assertArrayHasKey('test@wallabag.io', $msg->getTo());
71 $this->assertEquals(array('nobody@test.io' => 'wallabag test'), $msg->getFrom()); 71 $this->assertEquals(array('nobody@test.io' => 'wallabag test'), $msg->getFrom());
72 $this->assertEquals('auth_code subject', $msg->getSubject()); 72 $this->assertEquals('subject', $msg->getSubject());
73 $this->assertContains('Hi Bob, here is the code: 666666 and the support: http://0.0.0.0', $msg->toString()); 73 $this->assertContains('text body http://0.0.0.0/support', $msg->toString());
74 $this->assertContains('html body 666666', $msg->toString());
74 } 75 }
75} 76}