diff options
Diffstat (limited to 'tests/Wallabag/UserBundle')
4 files changed, 32 insertions, 23 deletions
diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index adc2cf09..f44e6fbf 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php | |||
@@ -1,6 +1,6 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Wallabag\UserBundle\Tests\Controller; | 3 | namespace Tests\Wallabag\UserBundle\Controller; |
4 | 4 | ||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | 5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; |
6 | 6 | ||
diff --git a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php index 2b540fdf..8a8ec3cf 100644 --- a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php +++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php | |||
@@ -8,6 +8,8 @@ use PHPUnit\Framework\TestCase; | |||
8 | use Symfony\Component\EventDispatcher\EventDispatcher; | 8 | use Symfony\Component\EventDispatcher\EventDispatcher; |
9 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
10 | use Symfony\Component\HttpFoundation\Response; | 10 | use Symfony\Component\HttpFoundation\Response; |
11 | use Symfony\Component\HttpFoundation\Session\Session; | ||
12 | use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; | ||
11 | use Wallabag\CoreBundle\Entity\Config; | 13 | use Wallabag\CoreBundle\Entity\Config; |
12 | use Wallabag\UserBundle\Entity\User; | 14 | use Wallabag\UserBundle\Entity\User; |
13 | use Wallabag\UserBundle\EventListener\CreateConfigListener; | 15 | use Wallabag\UserBundle\EventListener\CreateConfigListener; |
@@ -22,6 +24,7 @@ class CreateConfigListenerTest extends TestCase | |||
22 | 24 | ||
23 | protected function setUp() | 25 | protected function setUp() |
24 | { | 26 | { |
27 | $session = new Session(new MockArraySessionStorage()); | ||
25 | $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') | 28 | $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager') |
26 | ->disableOriginalConstructor() | 29 | ->disableOriginalConstructor() |
27 | ->getMock(); | 30 | ->getMock(); |
@@ -34,7 +37,8 @@ class CreateConfigListenerTest extends TestCase | |||
34 | 'fr', | 37 | 'fr', |
35 | 1, | 38 | 1, |
36 | 1, | 39 | 1, |
37 | 1 | 40 | 1, |
41 | $session | ||
38 | ); | 42 | ); |
39 | 43 | ||
40 | $this->dispatcher = new EventDispatcher(); | 44 | $this->dispatcher = new EventDispatcher(); |
@@ -58,13 +62,13 @@ class CreateConfigListenerTest extends TestCase | |||
58 | $config = new Config($user); | 62 | $config = new Config($user); |
59 | $config->setTheme('baggy'); | 63 | $config->setTheme('baggy'); |
60 | $config->setItemsPerPage(20); | 64 | $config->setItemsPerPage(20); |
61 | $config->setRssLimit(50); | 65 | $config->setFeedLimit(50); |
62 | $config->setLanguage('fr'); | 66 | $config->setLanguage('fr'); |
63 | $config->setReadingSpeed(1); | 67 | $config->setReadingSpeed(200); |
64 | 68 | ||
65 | $this->em->expects($this->once()) | 69 | $this->em->expects($this->once()) |
66 | ->method('persist') | 70 | ->method('persist') |
67 | ->will($this->returnValue($config)); | 71 | ->willReturn($config); |
68 | $this->em->expects($this->once()) | 72 | $this->em->expects($this->once()) |
69 | ->method('flush'); | 73 | ->method('flush'); |
70 | 74 | ||
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'); |
diff --git a/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php b/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php new file mode 100644 index 00000000..53f240a1 --- /dev/null +++ b/tests/Wallabag/UserBundle/Mailer/CountableMemorySpool.php | |||
@@ -0,0 +1,19 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\UserBundle\Mailer; | ||
4 | |||
5 | /** | ||
6 | * @see https://www.pmg.com/blog/integration-testing-swift-mailer/ | ||
7 | */ | ||
8 | final class CountableMemorySpool extends \Swift_MemorySpool implements \Countable | ||
9 | { | ||
10 | public function count() | ||
11 | { | ||
12 | return \count($this->messages); | ||
13 | } | ||
14 | |||
15 | public function getMessages() | ||
16 | { | ||
17 | return $this->messages; | ||
18 | } | ||
19 | } | ||