diff options
Diffstat (limited to 'tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php')
-rw-r--r-- | tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php index aa176068..4f93a92c 100644 --- a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php +++ b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php | |||
@@ -3,25 +3,11 @@ | |||
3 | namespace Tests\Wallabag\UserBundle\Mailer; | 3 | namespace Tests\Wallabag\UserBundle\Mailer; |
4 | 4 | ||
5 | use PHPUnit\Framework\TestCase; | 5 | use PHPUnit\Framework\TestCase; |
6 | use Twig\Environment; | ||
7 | use Twig\Loader\ArrayLoader; | ||
6 | use Wallabag\UserBundle\Entity\User; | 8 | use Wallabag\UserBundle\Entity\User; |
7 | use Wallabag\UserBundle\Mailer\AuthCodeMailer; | 9 | use Wallabag\UserBundle\Mailer\AuthCodeMailer; |
8 | 10 | ||
9 | /** | ||
10 | * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ | ||
11 | */ | ||
12 | final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable | ||
13 | { | ||
14 | public function count() | ||
15 | { | ||
16 | return \count($this->messages); | ||
17 | } | ||
18 | |||
19 | public function getMessages() | ||
20 | { | ||
21 | return $this->messages; | ||
22 | } | ||
23 | } | ||
24 | |||
25 | class AuthCodeMailerTest extends TestCase | 11 | class AuthCodeMailerTest extends TestCase |
26 | { | 12 | { |
27 | protected $mailer; | 13 | protected $mailer; |
@@ -43,13 +29,13 @@ class AuthCodeMailerTest extends TestCase | |||
43 | {% block body_text %}text body {{ support_url }}{% endblock %} | 29 | {% block body_text %}text body {{ support_url }}{% endblock %} |
44 | TWIG; | 30 | TWIG; |
45 | 31 | ||
46 | $this->twig = new \Twig_Environment(new \Twig_Loader_Array(['WallabagUserBundle:TwoFactor:email_auth_code.html.twig' => $twigTemplate])); | 32 | $this->twig = new Environment(new ArrayLoader(['WallabagUserBundle:TwoFactor:email_auth_code.html.twig' => $twigTemplate])); |
47 | } | 33 | } |
48 | 34 | ||
49 | public function testSendEmail() | 35 | public function testSendEmail() |
50 | { | 36 | { |
51 | $user = new User(); | 37 | $user = new User(); |
52 | $user->setTwoFactorAuthentication(true); | 38 | $user->setEmailTwoFactor(true); |
53 | $user->setEmailAuthCode(666666); | 39 | $user->setEmailAuthCode(666666); |
54 | $user->setEmail('test@wallabag.io'); | 40 | $user->setEmail('test@wallabag.io'); |
55 | $user->setName('Bob'); | 41 | $user->setName('Bob'); |