3 namespace Tests\Wallabag\UserBundle\EventListener
;
5 use FOS\UserBundle\Event\FilterUserResponseEvent
;
6 use FOS\UserBundle\FOSUserEvents
;
7 use PHPUnit\Framework\TestCase
;
8 use Symfony\Component\EventDispatcher\EventDispatcher
;
9 use Symfony\Component\HttpFoundation\Request
;
10 use Symfony\Component\HttpFoundation\Response
;
11 use Symfony\Component\HttpFoundation\Session\Session
;
12 use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage
;
13 use Wallabag\CoreBundle\Entity\Config
;
14 use Wallabag\UserBundle\Entity\User
;
15 use Wallabag\UserBundle\EventListener\CreateConfigListener
;
17 class CreateConfigListenerTest
extends TestCase
25 protected function setUp()
27 $session = new Session(new MockArraySessionStorage());
28 $this->em
= $this->getMockBuilder('Doctrine\ORM\EntityManager')
29 ->disableOriginalConstructor()
32 $this->listener
= new CreateConfigListener(
44 $this->dispatcher
= new EventDispatcher();
45 $this->dispatcher
->addSubscriber($this->listener
);
47 $this->request
= Request
::create('/');
48 $this->response
= Response
::create();
51 public function testWithValidUser()
54 $user->setEnabled(true);
56 $event = new FilterUserResponseEvent(
62 $config = new Config($user);
63 $config->setTheme('baggy');
64 $config->setItemsPerPage(20);
65 $config->setRssLimit(50);
66 $config->setLanguage('fr');
67 $config->setReadingSpeed(1);
69 $this->em
->expects($this->once())
71 ->will($this->returnValue($config));
72 $this->em
->expects($this->once())
75 $this->dispatcher
->dispatch(
76 FOSUserEvents
::REGISTRATION_COMPLETED
,