3 namespace Wallabag\CoreBundle\Tests\EventListener
;
5 use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase
;
6 use Symfony\Component\EventDispatcher\EventDispatcher
;
7 use Symfony\Component\HttpFoundation\Request
;
8 use Symfony\Component\HttpFoundation\Response
;
9 use FOS\UserBundle\FOSUserEvents
;
10 use FOS\UserBundle\Event\FilterUserResponseEvent
;
11 use Wallabag\CoreBundle\EventListener\RegistrationConfirmedListener
;
12 use Wallabag\CoreBundle\Entity\User
;
13 use Wallabag\CoreBundle\Entity\Config
;
15 class RegistrationConfirmedListenerTest
extends KernelTestCase
23 protected function setUp()
25 $this->em
= $this->getMockBuilder('Doctrine\ORM\EntityManager')
26 ->disableOriginalConstructor()
29 $this->listener
= new RegistrationConfirmedListener(
37 $this->dispatcher
= new EventDispatcher();
38 $this->dispatcher
->addSubscriber($this->listener
);
40 $this->request
= Request
::create('/');
41 $this->response
= Response
::create();
44 public function testWithInvalidUser()
47 $user->setEnabled(false);
49 $event = new FilterUserResponseEvent(
55 $this->em
->expects($this->never())->method('persist');
56 $this->em
->expects($this->never())->method('flush');
58 $this->dispatcher
->dispatch(
59 FOSUserEvents
::REGISTRATION_CONFIRMED
,
64 public function testWithValidUser()
67 $user->setEnabled(true);
69 $event = new FilterUserResponseEvent(
75 $config = new Config($user);
76 $config->setTheme('baggy');
77 $config->setItemsPerPage(20);
78 $config->setRssLimit(50);
79 $config->setLanguage('fr');
81 $this->em
->expects($this->once())
83 ->will($this->returnValue($config));
84 $this->em
->expects($this->once())
87 $this->dispatcher
->dispatch(
88 FOSUserEvents
::REGISTRATION_CONFIRMED
,