diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-10-01 15:51:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-01 15:51:37 +0200 |
commit | db5541e7a1e7131d62b4df23fa6eadd0c542b256 (patch) | |
tree | c5c71df873a9aa9350660e225f046a448274868f /tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php | |
parent | 114c55c0a6eade2ba6c53fe25f61cc58cca91620 (diff) | |
parent | fb7354c4a430f4f4916a1247aa1b1bf564ead0da (diff) | |
download | wallabag-db5541e7a1e7131d62b4df23fa6eadd0c542b256.tar.gz wallabag-db5541e7a1e7131d62b4df23fa6eadd0c542b256.tar.zst wallabag-db5541e7a1e7131d62b4df23fa6eadd0c542b256.zip |
Merge pull request #2320 from wallabag/user-config
Create user config in one place.
Diffstat (limited to 'tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php')
-rw-r--r-- | tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php | 91 |
1 files changed, 0 insertions, 91 deletions
diff --git a/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php b/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php deleted file mode 100644 index e45722fa..00000000 --- a/tests/Wallabag/CoreBundle/EventListener/RegistrationConfirmedListenerTest.php +++ /dev/null | |||
@@ -1,91 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\CoreBundle\EventListener; | ||
4 | |||
5 | use FOS\UserBundle\Event\FilterUserResponseEvent; | ||
6 | use FOS\UserBundle\FOSUserEvents; | ||
7 | use Symfony\Component\EventDispatcher\EventDispatcher; | ||
8 | use Symfony\Component\HttpFoundation\Request; | ||
9 | use Symfony\Component\HttpFoundation\Response; | ||
10 | use Wallabag\CoreBundle\Entity\Config; | ||
11 | use Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener; | ||
12 | use Wallabag\UserBundle\Entity\User; | ||
13 | |||
14 | class 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 | } | ||