diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-01-18 09:16:01 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-01-18 09:16:01 +0100 |
commit | 3080a4afa46a1d19c2f65c4fb321b1f4e2c38dc0 (patch) | |
tree | 0a3ef880443999636585dd17ff1f6147541b44ff /src/Wallabag/UserBundle | |
parent | 3bcc4d4cb29abeedb48b1f297f1a65a02998ff69 (diff) | |
parent | e678c4752a35b06c0a77d17fc23aa2de6abc4e18 (diff) | |
download | wallabag-3080a4afa46a1d19c2f65c4fb321b1f4e2c38dc0.tar.gz wallabag-3080a4afa46a1d19c2f65c4fb321b1f4e2c38dc0.tar.zst wallabag-3080a4afa46a1d19c2f65c4fb321b1f4e2c38dc0.zip |
Merge pull request #1587 from wallabag/v2-translator
Use translator interface instead of final class
Diffstat (limited to 'src/Wallabag/UserBundle')
-rw-r--r-- | src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php | 16 | ||||
-rw-r--r-- | src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php | 13 |
2 files changed, 13 insertions, 16 deletions
diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php index f1960070..be370e71 100644 --- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php | |||
@@ -4,7 +4,7 @@ namespace Wallabag\UserBundle\Mailer; | |||
4 | 4 | ||
5 | use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; | 5 | use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; |
6 | use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; | 6 | use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; |
7 | use Symfony\Component\Translation\DataCollectorTranslator; | 7 | use Symfony\Component\Translation\TranslatorInterface; |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Custom mailer for TwoFactorBundle email. | 10 | * Custom mailer for TwoFactorBundle email. |
@@ -22,7 +22,7 @@ class AuthCodeMailer implements AuthCodeMailerInterface | |||
22 | /** | 22 | /** |
23 | * Translator for email content. | 23 | * Translator for email content. |
24 | * | 24 | * |
25 | * @var DataCollectorTranslator | 25 | * @var TranslatorInterface |
26 | */ | 26 | */ |
27 | private $translator; | 27 | private $translator; |
28 | 28 | ||
@@ -50,13 +50,13 @@ class AuthCodeMailer implements AuthCodeMailerInterface | |||
50 | /** | 50 | /** |
51 | * Initialize the auth code mailer with the SwiftMailer object. | 51 | * Initialize the auth code mailer with the SwiftMailer object. |
52 | * | 52 | * |
53 | * @param \Swift_Mailer $mailer | 53 | * @param \Swift_Mailer $mailer |
54 | * @param DataCollectorTranslator $translator | 54 | * @param TranslatorInterface $translator |
55 | * @param string $senderEmail | 55 | * @param string $senderEmail |
56 | * @param string $senderName | 56 | * @param string $senderName |
57 | * @param string $supportUrl | 57 | * @param string $supportUrl |
58 | */ | 58 | */ |
59 | public function __construct(\Swift_Mailer $mailer, DataCollectorTranslator $translator, $senderEmail, $senderName, $supportUrl) | 59 | public function __construct(\Swift_Mailer $mailer, TranslatorInterface $translator, $senderEmail, $senderName, $supportUrl) |
60 | { | 60 | { |
61 | $this->mailer = $mailer; | 61 | $this->mailer = $mailer; |
62 | $this->translator = $translator; | 62 | $this->translator = $translator; |
diff --git a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php index 9122576a..61e960f9 100644 --- a/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php +++ b/src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php | |||
@@ -6,7 +6,6 @@ use Wallabag\UserBundle\Entity\User; | |||
6 | use Wallabag\UserBundle\Mailer\AuthCodeMailer; | 6 | use Wallabag\UserBundle\Mailer\AuthCodeMailer; |
7 | use Symfony\Component\Translation\Translator; | 7 | use Symfony\Component\Translation\Translator; |
8 | use Symfony\Component\Translation\Loader\ArrayLoader; | 8 | use Symfony\Component\Translation\Loader\ArrayLoader; |
9 | use Symfony\Component\Translation\DataCollectorTranslator; | ||
10 | 9 | ||
11 | /** | 10 | /** |
12 | * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ | 11 | * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ |
@@ -28,7 +27,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase | |||
28 | { | 27 | { |
29 | protected $mailer; | 28 | protected $mailer; |
30 | protected $spool; | 29 | protected $spool; |
31 | protected $dataCollector; | 30 | protected $translator; |
32 | 31 | ||
33 | protected function setUp() | 32 | protected function setUp() |
34 | { | 33 | { |
@@ -39,14 +38,12 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase | |||
39 | ); | 38 | ); |
40 | $this->mailer = new \Swift_Mailer($transport); | 39 | $this->mailer = new \Swift_Mailer($transport); |
41 | 40 | ||
42 | $translator = new Translator('en'); | 41 | $this->translator = new Translator('en'); |
43 | $translator->addLoader('array', new ArrayLoader()); | 42 | $this->translator->addLoader('array', new ArrayLoader()); |
44 | $translator->addResource('array', array( | 43 | $this->translator->addResource('array', array( |
45 | 'auth_code.mailer.subject' => 'auth_code subject', | 44 | 'auth_code.mailer.subject' => 'auth_code subject', |
46 | 'auth_code.mailer.body' => 'Hi %user%, here is the code: %code% and the support: %support%', | 45 | 'auth_code.mailer.body' => 'Hi %user%, here is the code: %code% and the support: %support%', |
47 | ), 'en', 'wallabag_user'); | 46 | ), 'en', 'wallabag_user'); |
48 | |||
49 | $this->dataCollector = new DataCollectorTranslator($translator); | ||
50 | } | 47 | } |
51 | 48 | ||
52 | public function testSendEmail() | 49 | public function testSendEmail() |
@@ -59,7 +56,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase | |||
59 | 56 | ||
60 | $authCodeMailer = new AuthCodeMailer( | 57 | $authCodeMailer = new AuthCodeMailer( |
61 | $this->mailer, | 58 | $this->mailer, |
62 | $this->dataCollector, | 59 | $this->translator, |
63 | 'nobody@test.io', | 60 | 'nobody@test.io', |
64 | 'wallabag test', | 61 | 'wallabag test', |
65 | 'http://0.0.0.0' | 62 | 'http://0.0.0.0' |