diff options
Diffstat (limited to 'src/Wallabag/UserBundle')
-rw-r--r-- | src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig | 2 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php | 84 |
2 files changed, 1 insertions, 85 deletions
diff --git a/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig b/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig index c44fcfb7..3731f13b 100644 --- a/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/TwoFactor/email_auth_code.html.twig | |||
@@ -74,7 +74,7 @@ | |||
74 | 74 | ||
75 | <table cellpadding="0" cellspacing="0" border="0" align="center" id="card"> | 75 | <table cellpadding="0" cellspacing="0" border="0" align="center" id="card"> |
76 | <tr> | 76 | <tr> |
77 | <td style="padding: 20px;" width="96px" valign="top"><img class="image_fix" src="{{ wallabag_url }}/themes/material/img/logo-other_themes.png" alt="logo" title="{{ wallabag_url }}" style="width: 96px; height: 96px;" /></td> | 77 | <td style="padding: 20px;" width="96px" valign="top"><img class="image_fix" src="{{ asset('bundles/wallabagcore/themes/material/img/logo-other_themes.png') }}" alt="logo" title="{{ wallabag_url }}" style="width: 96px; height: 96px;" /></td> |
78 | <td style="padding: 20px; padding-left: 0;" valign="top" id="cell_desc"> | 78 | <td style="padding: 20px; padding-left: 0;" valign="top" id="cell_desc"> |
79 | <h1>wallabag</h1> | 79 | <h1>wallabag</h1> |
80 | <h5>{{ "auth_code.on"|trans({}, 'wallabag_user') }} {{ wallabag_url }}</h5> | 80 | <h5>{{ "auth_code.on"|trans({}, 'wallabag_user') }} {{ wallabag_url }}</h5> |
diff --git a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php deleted file mode 100644 index 00967051..00000000 --- a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\UserBundle\Tests\Mailer; | ||
4 | |||
5 | use Wallabag\UserBundle\Entity\User; | ||
6 | use Wallabag\UserBundle\Mailer\AuthCodeMailer; | ||
7 | |||
8 | /** | ||
9 | * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ | ||
10 | */ | ||
11 | final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable | ||
12 | { | ||
13 | public function count() | ||
14 | { | ||
15 | return count($this->messages); | ||
16 | } | ||
17 | |||
18 | public function getMessages() | ||
19 | { | ||
20 | return $this->messages; | ||
21 | } | ||
22 | } | ||
23 | |||
24 | class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase | ||
25 | { | ||
26 | protected $mailer; | ||
27 | protected $spool; | ||
28 | protected $twig; | ||
29 | protected $config; | ||
30 | |||
31 | protected function setUp() | ||
32 | { | ||
33 | $this->spool = new CountableMemorySpool(); | ||
34 | $transport = new \Swift_Transport_SpoolTransport( | ||
35 | new \Swift_Events_SimpleEventDispatcher(), | ||
36 | $this->spool | ||
37 | ); | ||
38 | $this->mailer = new \Swift_Mailer($transport); | ||
39 | |||
40 | $twigTemplate = <<<TWIG | ||
41 | {% block subject %}subject{% endblock %} | ||
42 | {% block body_html %}html body {{ code }}{% endblock %} | ||
43 | {% block body_text %}text body {{ support_url }}{% endblock %} | ||
44 | TWIG; | ||
45 | |||
46 | $this->twig = new \Twig_Environment(new \Twig_Loader_Array(['WallabagUserBundle:TwoFactor:email_auth_code.html.twig' => $twigTemplate])); | ||
47 | |||
48 | $this->config = $this->getMockBuilder('Craue\ConfigBundle\Util\Config') | ||
49 | ->disableOriginalConstructor() | ||
50 | ->getMock(); | ||
51 | |||
52 | $this->config->expects($this->any()) | ||
53 | ->method('get') | ||
54 | ->willReturn('http://0.0.0.0/support'); | ||
55 | } | ||
56 | |||
57 | public function testSendEmail() | ||
58 | { | ||
59 | $user = new User(); | ||
60 | $user->setTwoFactorAuthentication(true); | ||
61 | $user->setEmailAuthCode(666666); | ||
62 | $user->setEmail('test@wallabag.io'); | ||
63 | $user->setName('Bob'); | ||
64 | |||
65 | $authCodeMailer = new AuthCodeMailer( | ||
66 | $this->mailer, | ||
67 | $this->twig, | ||
68 | 'nobody@test.io', | ||
69 | 'wallabag test', | ||
70 | $this->config | ||
71 | ); | ||
72 | |||
73 | $authCodeMailer->sendAuthCode($user); | ||
74 | |||
75 | $this->assertCount(1, $this->spool); | ||
76 | |||
77 | $msg = $this->spool->getMessages()[0]; | ||
78 | $this->assertArrayHasKey('test@wallabag.io', $msg->getTo()); | ||
79 | $this->assertEquals(['nobody@test.io' => 'wallabag test'], $msg->getFrom()); | ||
80 | $this->assertEquals('subject', $msg->getSubject()); | ||
81 | $this->assertContains('text body http://0.0.0.0/support', $msg->toString()); | ||
82 | $this->assertContains('html body 666666', $msg->toString()); | ||
83 | } | ||
84 | } | ||