aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-06-23 09:18:18 +0200
committerGitHub <noreply@github.com>2016-06-23 09:18:18 +0200
commitd37bb05c881bfdbeb1144b327edd4dcc2cbb163f (patch)
tree1b90f7e733a83af4741a8cb7f49edf3e303f8677 /tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php
parent891a026e31ad54ca90b70f6026f23260cfadb7fd (diff)
parent99451fe4b76051d61922a6beb7ee9e79cc6e7893 (diff)
downloadwallabag-d37bb05c881bfdbeb1144b327edd4dcc2cbb163f.tar.gz
wallabag-d37bb05c881bfdbeb1144b327edd4dcc2cbb163f.tar.zst
wallabag-d37bb05c881bfdbeb1144b327edd4dcc2cbb163f.zip
Merge pull request #2132 from wallabag/sf3.1
Jump to Symfony 3.1
Diffstat (limited to 'tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php')
-rw-r--r--tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php91
1 files changed, 91 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php b/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php
new file mode 100644
index 00000000..e45722fa
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php
@@ -0,0 +1,91 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\EventListener;
4
5use FOS\UserBundle\Event\FilterUserResponseEvent;
6use FOS\UserBundle\FOSUserEvents;
7use Symfony\Component\EventDispatcher\EventDispatcher;
8use Symfony\Component\HttpFoundation\Request;
9use Symfony\Component\HttpFoundation\Response;
10use Wallabag\CoreBundle\Entity\Config;
11use Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener;
12use Wallabag\UserBundle\Entity\User;
13
14class RegistrationConfirmedListenerTest extends \PHPUnit_Framework_TestCase
15{
16 private $em;
17 private $listener;
18 private $dispatcher;
19 private $request;
20 private $response;
21
22 protected function setUp()
23 {
24 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
25 ->disableOriginalConstructor()
26 ->getMock();
27
28 $this->listener = new RegistrationConfirmedListener(
29 $this->em,
30 'baggy',
31 20,
32 50,
33 'fr'
34 );
35
36 $this->dispatcher = new EventDispatcher();
37 $this->dispatcher->addSubscriber($this->listener);
38
39 $this->request = Request::create('/');
40 $this->response = Response::create();
41 }
42
43 public function testWithInvalidUser()
44 {
45 $user = new User();
46 $user->setEnabled(false);
47
48 $event = new FilterUserResponseEvent(
49 $user,
50 $this->request,
51 $this->response
52 );
53
54 $this->em->expects($this->never())->method('persist');
55 $this->em->expects($this->never())->method('flush');
56
57 $this->dispatcher->dispatch(
58 FOSUserEvents::REGISTRATION_CONFIRMED,
59 $event
60 );
61 }
62
63 public function testWithValidUser()
64 {
65 $user = new User();
66 $user->setEnabled(true);
67
68 $event = new FilterUserResponseEvent(
69 $user,
70 $this->request,
71 $this->response
72 );
73
74 $config = new Config($user);
75 $config->setTheme('baggy');
76 $config->setItemsPerPage(20);
77 $config->setRssLimit(50);
78 $config->setLanguage('fr');
79
80 $this->em->expects($this->once())
81 ->method('persist')
82 ->will($this->returnValue($config));
83 $this->em->expects($this->once())
84 ->method('flush');
85
86 $this->dispatcher->dispatch(
87 FOSUserEvents::REGISTRATION_CONFIRMED,
88 $event
89 );
90 }
91}