From e678c4752a35b06c0a77d17fc23aa2de6abc4e18 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sun, 17 Jan 2016 12:52:30 +0100 Subject: Use translator interface instead of final class Symfony use a different class when in dev mode and prod mode. Prod loads `Symfony\Bundle\FrameworkBundle\Translation\Translator`. Dev loads `Symfony\Component\Translation\DataCollectorTranslator` to gather information for the debug bar. Fix #1585 --- src/Wallabag/UserBundle/Tests/Mailer/AuthCodeMailerTest.php | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/Wallabag/UserBundle/Tests') 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; use Wallabag\UserBundle\Mailer\AuthCodeMailer; use Symfony\Component\Translation\Translator; use Symfony\Component\Translation\Loader\ArrayLoader; -use Symfony\Component\Translation\DataCollectorTranslator; /** * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ @@ -28,7 +27,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase { protected $mailer; protected $spool; - protected $dataCollector; + protected $translator; protected function setUp() { @@ -39,14 +38,12 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase ); $this->mailer = new \Swift_Mailer($transport); - $translator = new Translator('en'); - $translator->addLoader('array', new ArrayLoader()); - $translator->addResource('array', array( + $this->translator = new Translator('en'); + $this->translator->addLoader('array', new ArrayLoader()); + $this->translator->addResource('array', array( 'auth_code.mailer.subject' => 'auth_code subject', 'auth_code.mailer.body' => 'Hi %user%, here is the code: %code% and the support: %support%', ), 'en', 'wallabag_user'); - - $this->dataCollector = new DataCollectorTranslator($translator); } public function testSendEmail() @@ -59,7 +56,7 @@ class AuthCodeMailerTest extends \PHPUnit_Framework_TestCase $authCodeMailer = new AuthCodeMailer( $this->mailer, - $this->dataCollector, + $this->translator, 'nobody@test.io', 'wallabag test', 'http://0.0.0.0' -- cgit v1.2.3