aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php60
-rw-r--r--tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php (renamed from tests/Wallabag/CoreBundle/EventListener/LocaleListenerTest.php)4
-rw-r--r--tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php (renamed from tests/Wallabag/CoreBundle/EventListener/UserLocaleListenerTest.php)4
-rw-r--r--tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php (renamed from tests/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriberTest.php)4
-rw-r--r--tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php143
-rw-r--r--tests/Wallabag/CoreBundle/fixtures/unnamed.pngbin0 -> 3688 bytes
-rw-r--r--tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php33
-rw-r--r--tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php33
-rw-r--r--tests/Wallabag/ImportBundle/Import/ChromeImportTest.php16
-rw-r--r--tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php16
-rw-r--r--tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php16
-rw-r--r--tests/Wallabag/ImportBundle/Import/PocketImportTest.php21
-rw-r--r--tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php16
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php16
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php18
15 files changed, 355 insertions, 45 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 05113650..4ab06dbf 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -836,4 +836,64 @@ class EntryControllerTest extends WallabagCoreTestCase
836 $client->request('GET', '/share/'.$content->getUuid()); 836 $client->request('GET', '/share/'.$content->getUuid());
837 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 837 $this->assertEquals(404, $client->getResponse()->getStatusCode());
838 } 838 }
839
840 public function testNewEntryWithDownloadImagesEnabled()
841 {
842 $this->logInAs('admin');
843 $client = $this->getClient();
844
845 $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route';
846 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
847
848 $crawler = $client->request('GET', '/new');
849
850 $this->assertEquals(200, $client->getResponse()->getStatusCode());
851
852 $form = $crawler->filter('form[name=entry]')->form();
853
854 $data = [
855 'entry[url]' => $url,
856 ];
857
858 $client->submit($form, $data);
859
860 $this->assertEquals(302, $client->getResponse()->getStatusCode());
861
862 $em = $client->getContainer()
863 ->get('doctrine.orm.entity_manager');
864
865 $entry = $em
866 ->getRepository('WallabagCoreBundle:Entry')
867 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
868
869 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
870 $this->assertEquals($url, $entry->getUrl());
871 $this->assertContains('Perpignan', $entry->getTitle());
872 $this->assertContains('/d9bc0fcd.jpeg', $entry->getContent());
873
874 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
875 }
876
877 /**
878 * @depends testNewEntryWithDownloadImagesEnabled
879 */
880 public function testRemoveEntryWithDownloadImagesEnabled()
881 {
882 $this->logInAs('admin');
883 $client = $this->getClient();
884
885 $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route';
886 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
887
888 $content = $client->getContainer()
889 ->get('doctrine.orm.entity_manager')
890 ->getRepository('WallabagCoreBundle:Entry')
891 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
892
893 $client->request('GET', '/delete/'.$content->getId());
894
895 $this->assertEquals(302, $client->getResponse()->getStatusCode());
896
897 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
898 }
839} 899}
diff --git a/tests/Wallabag/CoreBundle/EventListener/LocaleListenerTest.php b/tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php
index 078bb69a..84a54d3a 100644
--- a/tests/Wallabag/CoreBundle/EventListener/LocaleListenerTest.php
+++ b/tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Tests\Wallabag\CoreBundle\EventListener; 3namespace Tests\Wallabag\CoreBundle\Event\Listener;
4 4
5use Symfony\Component\EventDispatcher\EventDispatcher; 5use Symfony\Component\EventDispatcher\EventDispatcher;
6use Symfony\Component\HttpFoundation\Request; 6use Symfony\Component\HttpFoundation\Request;
@@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
9use Symfony\Component\HttpKernel\Event\GetResponseEvent; 9use Symfony\Component\HttpKernel\Event\GetResponseEvent;
10use Symfony\Component\HttpKernel\HttpKernelInterface; 10use Symfony\Component\HttpKernel\HttpKernelInterface;
11use Symfony\Component\HttpKernel\KernelEvents; 11use Symfony\Component\HttpKernel\KernelEvents;
12use Wallabag\CoreBundle\EventListener\LocaleListener; 12use Wallabag\CoreBundle\Event\Listener\LocaleListener;
13 13
14class LocaleListenerTest extends \PHPUnit_Framework_TestCase 14class LocaleListenerTest extends \PHPUnit_Framework_TestCase
15{ 15{
diff --git a/tests/Wallabag/CoreBundle/EventListener/UserLocaleListenerTest.php b/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
index e9ac7c1d..45aecc63 100644
--- a/tests/Wallabag/CoreBundle/EventListener/UserLocaleListenerTest.php
+++ b/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2 2
3namespace Tests\Wallabag\CoreBundle\EventListener; 3namespace Tests\Wallabag\CoreBundle\Event\Listener;
4 4
5use Symfony\Component\HttpFoundation\Request; 5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Component\HttpFoundation\Session\Session; 6use Symfony\Component\HttpFoundation\Session\Session;
@@ -8,7 +8,7 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
8use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; 8use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
9use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; 9use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
10use Wallabag\CoreBundle\Entity\Config; 10use Wallabag\CoreBundle\Entity\Config;
11use Wallabag\CoreBundle\EventListener\UserLocaleListener; 11use Wallabag\CoreBundle\Event\Listener\UserLocaleListener;
12use Wallabag\UserBundle\Entity\User; 12use Wallabag\UserBundle\Entity\User;
13 13
14class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase 14class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriberTest.php b/tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php
index 4ae76703..b8cd0fad 100644
--- a/tests/Wallabag/CoreBundle/Subscriber/TablePrefixSubscriberTest.php
+++ b/tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php
@@ -1,11 +1,11 @@
1<?php 1<?php
2 2
3namespace Tests\Wallabag\CoreBundle\Subscriber; 3namespace Tests\Wallabag\CoreBundle\Event\Subscriber;
4 4
5use Doctrine\Common\EventManager; 5use Doctrine\Common\EventManager;
6use Doctrine\ORM\Event\LoadClassMetadataEventArgs; 6use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
7use Doctrine\ORM\Mapping\ClassMetadata; 7use Doctrine\ORM\Mapping\ClassMetadata;
8use Wallabag\CoreBundle\Subscriber\TablePrefixSubscriber; 8use Wallabag\CoreBundle\Event\Subscriber\TablePrefixSubscriber;
9 9
10class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase 10class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
11{ 11{
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
new file mode 100644
index 00000000..920c21d9
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
@@ -0,0 +1,143 @@
1<?php
2
3namespace Tests\Wallabag\CoreBundle\Helper;
4
5use Wallabag\CoreBundle\Helper\DownloadImages;
6use Psr\Log\NullLogger;
7use Monolog\Logger;
8use Monolog\Handler\TestHandler;
9use GuzzleHttp\Client;
10use GuzzleHttp\Subscriber\Mock;
11use GuzzleHttp\Message\Response;
12use GuzzleHttp\Stream\Stream;
13
14class DownloadImagesTest extends \PHPUnit_Framework_TestCase
15{
16 public function testProcessHtml()
17 {
18 $client = new Client();
19
20 $mock = new Mock([
21 new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
22 ]);
23
24 $client->getEmitter()->attach($mock);
25
26 $logHandler = new TestHandler();
27 $logger = new Logger('test', array($logHandler));
28
29 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
30
31 $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
32
33 $this->assertContains('http://wallabag.io/assets/images/9/b/9b0ead26/c638b4c2.png', $res);
34 }
35
36 public function testProcessHtmlWithBadImage()
37 {
38 $client = new Client();
39
40 $mock = new Mock([
41 new Response(200, ['content-type' => 'application/json'], Stream::factory('')),
42 ]);
43
44 $client->getEmitter()->attach($mock);
45
46 $logHandler = new TestHandler();
47 $logger = new Logger('test', array($logHandler));
48
49 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
50 $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
51
52 $this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type');
53 }
54
55 public function singleImage()
56 {
57 return [
58 ['image/pjpeg', 'jpeg'],
59 ['image/jpeg', 'jpeg'],
60 ['image/png', 'png'],
61 ['image/gif', 'gif'],
62 ];
63 }
64
65 /**
66 * @dataProvider singleImage
67 */
68 public function testProcessSingleImage($header, $extension)
69 {
70 $client = new Client();
71
72 $mock = new Mock([
73 new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
74 ]);
75
76 $client->getEmitter()->attach($mock);
77
78 $logHandler = new TestHandler();
79 $logger = new Logger('test', array($logHandler));
80
81 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
82 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
83
84 $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.'.$extension, $res);
85 }
86
87 public function testProcessSingleImageWithBadUrl()
88 {
89 $client = new Client();
90
91 $mock = new Mock([
92 new Response(404, []),
93 ]);
94
95 $client->getEmitter()->attach($mock);
96
97 $logHandler = new TestHandler();
98 $logger = new Logger('test', array($logHandler));
99
100 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
101 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
102
103 $this->assertFalse($res, 'Image can not be found, so it will not be replaced');
104 }
105
106 public function testProcessSingleImageWithBadImage()
107 {
108 $client = new Client();
109
110 $mock = new Mock([
111 new Response(200, ['content-type' => 'image/png'], Stream::factory('')),
112 ]);
113
114 $client->getEmitter()->attach($mock);
115
116 $logHandler = new TestHandler();
117 $logger = new Logger('test', array($logHandler));
118
119 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
120 $res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
121
122 $this->assertFalse($res, 'Image can not be loaded, so it will not be replaced');
123 }
124
125 public function testProcessSingleImageFailAbsolute()
126 {
127 $client = new Client();
128
129 $mock = new Mock([
130 new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))),
131 ]);
132
133 $client->getEmitter()->attach($mock);
134
135 $logHandler = new TestHandler();
136 $logger = new Logger('test', array($logHandler));
137
138 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger);
139 $res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY');
140
141 $this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced');
142 }
143}
diff --git a/tests/Wallabag/CoreBundle/fixtures/unnamed.png b/tests/Wallabag/CoreBundle/fixtures/unnamed.png
new file mode 100644
index 00000000..e6dd9caa
--- /dev/null
+++ b/tests/Wallabag/CoreBundle/fixtures/unnamed.png
Binary files differ
diff --git a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
index a3263771..856954a6 100644
--- a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
+++ b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
@@ -112,10 +112,19 @@ JSON;
112 ->with(json_decode($body, true)) 112 ->with(json_decode($body, true))
113 ->willReturn($entry); 113 ->willReturn($entry);
114 114
115 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
116 ->disableOriginalConstructor()
117 ->getMock();
118
119 $dispatcher
120 ->expects($this->once())
121 ->method('dispatch');
122
115 $consumer = new AMQPEntryConsumer( 123 $consumer = new AMQPEntryConsumer(
116 $em, 124 $em,
117 $userRepository, 125 $userRepository,
118 $import 126 $import,
127 $dispatcher
119 ); 128 );
120 129
121 $message = new AMQPMessage($body); 130 $message = new AMQPMessage($body);
@@ -157,10 +166,19 @@ JSON;
157 ->disableOriginalConstructor() 166 ->disableOriginalConstructor()
158 ->getMock(); 167 ->getMock();
159 168
169 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
170 ->disableOriginalConstructor()
171 ->getMock();
172
173 $dispatcher
174 ->expects($this->never())
175 ->method('dispatch');
176
160 $consumer = new AMQPEntryConsumer( 177 $consumer = new AMQPEntryConsumer(
161 $em, 178 $em,
162 $userRepository, 179 $userRepository,
163 $import 180 $import,
181 $dispatcher
164 ); 182 );
165 183
166 $message = new AMQPMessage($body); 184 $message = new AMQPMessage($body);
@@ -212,10 +230,19 @@ JSON;
212 ->with(json_decode($body, true)) 230 ->with(json_decode($body, true))
213 ->willReturn(null); 231 ->willReturn(null);
214 232
233 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
234 ->disableOriginalConstructor()
235 ->getMock();
236
237 $dispatcher
238 ->expects($this->never())
239 ->method('dispatch');
240
215 $consumer = new AMQPEntryConsumer( 241 $consumer = new AMQPEntryConsumer(
216 $em, 242 $em,
217 $userRepository, 243 $userRepository,
218 $import 244 $import,
245 $dispatcher
219 ); 246 );
220 247
221 $message = new AMQPMessage($body); 248 $message = new AMQPMessage($body);
diff --git a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
index 01a92ad2..3b92f759 100644
--- a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
+++ b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
@@ -111,10 +111,19 @@ JSON;
111 ->with(json_decode($body, true)) 111 ->with(json_decode($body, true))
112 ->willReturn($entry); 112 ->willReturn($entry);
113 113
114 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
115 ->disableOriginalConstructor()
116 ->getMock();
117
118 $dispatcher
119 ->expects($this->once())
120 ->method('dispatch');
121
114 $consumer = new RedisEntryConsumer( 122 $consumer = new RedisEntryConsumer(
115 $em, 123 $em,
116 $userRepository, 124 $userRepository,
117 $import 125 $import,
126 $dispatcher
118 ); 127 );
119 128
120 $res = $consumer->manage($body); 129 $res = $consumer->manage($body);
@@ -156,10 +165,19 @@ JSON;
156 ->disableOriginalConstructor() 165 ->disableOriginalConstructor()
157 ->getMock(); 166 ->getMock();
158 167
168 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
169 ->disableOriginalConstructor()
170 ->getMock();
171
172 $dispatcher
173 ->expects($this->never())
174 ->method('dispatch');
175
159 $consumer = new RedisEntryConsumer( 176 $consumer = new RedisEntryConsumer(
160 $em, 177 $em,
161 $userRepository, 178 $userRepository,
162 $import 179 $import,
180 $dispatcher
163 ); 181 );
164 182
165 $res = $consumer->manage($body); 183 $res = $consumer->manage($body);
@@ -211,10 +229,19 @@ JSON;
211 ->with(json_decode($body, true)) 229 ->with(json_decode($body, true))
212 ->willReturn(null); 230 ->willReturn(null);
213 231
232 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
233 ->disableOriginalConstructor()
234 ->getMock();
235
236 $dispatcher
237 ->expects($this->never())
238 ->method('dispatch');
239
214 $consumer = new RedisEntryConsumer( 240 $consumer = new RedisEntryConsumer(
215 $em, 241 $em,
216 $userRepository, 242 $userRepository,
217 $import 243 $import,
244 $dispatcher
218 ); 245 );
219 246
220 $res = $consumer->manage($body); 247 $res = $consumer->manage($body);
diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
index 1e52615c..6b3adda4 100644
--- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
@@ -18,7 +18,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 20
21 private function getChromeImport($unsetUser = false) 21 private function getChromeImport($unsetUser = false, $dispatched = 0)
22 { 22 {
23 $this->user = new User(); 23 $this->user = new User();
24 24
@@ -30,7 +30,15 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 30 ->disableOriginalConstructor()
31 ->getMock(); 31 ->getMock();
32 32
33 $wallabag = new ChromeImport($this->em, $this->contentProxy); 33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor()
35 ->getMock();
36
37 $dispatcher
38 ->expects($this->exactly($dispatched))
39 ->method('dispatch');
40
41 $wallabag = new ChromeImport($this->em, $this->contentProxy, $dispatcher);
34 42
35 $this->logHandler = new TestHandler(); 43 $this->logHandler = new TestHandler();
36 $logger = new Logger('test', [$this->logHandler]); 44 $logger = new Logger('test', [$this->logHandler]);
@@ -54,7 +62,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
54 62
55 public function testImport() 63 public function testImport()
56 { 64 {
57 $chromeImport = $this->getChromeImport(); 65 $chromeImport = $this->getChromeImport(false, 1);
58 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); 66 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
59 67
60 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 68 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -87,7 +95,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
87 95
88 public function testImportAndMarkAllAsRead() 96 public function testImportAndMarkAllAsRead()
89 { 97 {
90 $chromeImport = $this->getChromeImport(); 98 $chromeImport = $this->getChromeImport(false, 1);
91 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); 99 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
92 100
93 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 101 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
index 007dda6a..b516fbc5 100644
--- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
@@ -18,7 +18,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 20
21 private function getFirefoxImport($unsetUser = false) 21 private function getFirefoxImport($unsetUser = false, $dispatched = 0)
22 { 22 {
23 $this->user = new User(); 23 $this->user = new User();
24 24
@@ -30,7 +30,15 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 30 ->disableOriginalConstructor()
31 ->getMock(); 31 ->getMock();
32 32
33 $wallabag = new FirefoxImport($this->em, $this->contentProxy); 33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor()
35 ->getMock();
36
37 $dispatcher
38 ->expects($this->exactly($dispatched))
39 ->method('dispatch');
40
41 $wallabag = new FirefoxImport($this->em, $this->contentProxy, $dispatcher);
34 42
35 $this->logHandler = new TestHandler(); 43 $this->logHandler = new TestHandler();
36 $logger = new Logger('test', [$this->logHandler]); 44 $logger = new Logger('test', [$this->logHandler]);
@@ -54,7 +62,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
54 62
55 public function testImport() 63 public function testImport()
56 { 64 {
57 $firefoxImport = $this->getFirefoxImport(); 65 $firefoxImport = $this->getFirefoxImport(false, 2);
58 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); 66 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
59 67
60 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 68 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -87,7 +95,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
87 95
88 public function testImportAndMarkAllAsRead() 96 public function testImportAndMarkAllAsRead()
89 { 97 {
90 $firefoxImport = $this->getFirefoxImport(); 98 $firefoxImport = $this->getFirefoxImport(false, 1);
91 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); 99 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json');
92 100
93 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 101 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
index 75900bd7..e262a808 100644
--- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
@@ -18,7 +18,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 20
21 private function getInstapaperImport($unsetUser = false) 21 private function getInstapaperImport($unsetUser = false, $dispatched = 0)
22 { 22 {
23 $this->user = new User(); 23 $this->user = new User();
24 24
@@ -30,7 +30,15 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 30 ->disableOriginalConstructor()
31 ->getMock(); 31 ->getMock();
32 32
33 $import = new InstapaperImport($this->em, $this->contentProxy); 33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor()
35 ->getMock();
36
37 $dispatcher
38 ->expects($this->exactly($dispatched))
39 ->method('dispatch');
40
41 $import = new InstapaperImport($this->em, $this->contentProxy, $dispatcher);
34 42
35 $this->logHandler = new TestHandler(); 43 $this->logHandler = new TestHandler();
36 $logger = new Logger('test', [$this->logHandler]); 44 $logger = new Logger('test', [$this->logHandler]);
@@ -54,7 +62,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
54 62
55 public function testImport() 63 public function testImport()
56 { 64 {
57 $instapaperImport = $this->getInstapaperImport(); 65 $instapaperImport = $this->getInstapaperImport(false, 3);
58 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 66 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
59 67
60 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 68 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -87,7 +95,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
87 95
88 public function testImportAndMarkAllAsRead() 96 public function testImportAndMarkAllAsRead()
89 { 97 {
90 $instapaperImport = $this->getInstapaperImport(); 98 $instapaperImport = $this->getInstapaperImport(false, 1);
91 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 99 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
92 100
93 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 101 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
index 9ec7935c..141ece36 100644
--- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
@@ -24,7 +24,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
24 protected $contentProxy; 24 protected $contentProxy;
25 protected $logHandler; 25 protected $logHandler;
26 26
27 private function getPocketImport($consumerKey = 'ConsumerKey') 27 private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0)
28 { 28 {
29 $this->user = new User(); 29 $this->user = new User();
30 30
@@ -55,10 +55,15 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
55 ->method('getScheduledEntityInsertions') 55 ->method('getScheduledEntityInsertions')
56 ->willReturn([]); 56 ->willReturn([]);
57 57
58 $pocket = new PocketImport( 58 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
59 $this->em, 59 ->disableOriginalConstructor()
60 $this->contentProxy 60 ->getMock();
61 ); 61
62 $dispatcher
63 ->expects($this->exactly($dispatched))
64 ->method('dispatch');
65
66 $pocket = new PocketImport($this->em, $this->contentProxy, $dispatcher);
62 $pocket->setUser($this->user); 67 $pocket->setUser($this->user);
63 68
64 $this->logHandler = new TestHandler(); 69 $this->logHandler = new TestHandler();
@@ -252,7 +257,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
252 257
253 $client->getEmitter()->attach($mock); 258 $client->getEmitter()->attach($mock);
254 259
255 $pocketImport = $this->getPocketImport(); 260 $pocketImport = $this->getPocketImport('ConsumerKey', 1);
256 261
257 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 262 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
258 ->disableOriginalConstructor() 263 ->disableOriginalConstructor()
@@ -339,7 +344,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
339 344
340 $client->getEmitter()->attach($mock); 345 $client->getEmitter()->attach($mock);
341 346
342 $pocketImport = $this->getPocketImport(); 347 $pocketImport = $this->getPocketImport('ConsumerKey', 2);
343 348
344 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 349 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
345 ->disableOriginalConstructor() 350 ->disableOriginalConstructor()
@@ -591,7 +596,7 @@ JSON;
591 596
592 $client->getEmitter()->attach($mock); 597 $client->getEmitter()->attach($mock);
593 598
594 $pocketImport = $this->getPocketImport(); 599 $pocketImport = $this->getPocketImport('ConsumerKey', 1);
595 600
596 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 601 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
597 ->disableOriginalConstructor() 602 ->disableOriginalConstructor()
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
index d98cd486..d1bbe648 100644
--- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
@@ -18,7 +18,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 20
21 private function getReadabilityImport($unsetUser = false) 21 private function getReadabilityImport($unsetUser = false, $dispatched = 0)
22 { 22 {
23 $this->user = new User(); 23 $this->user = new User();
24 24
@@ -30,7 +30,15 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
30 ->disableOriginalConstructor() 30 ->disableOriginalConstructor()
31 ->getMock(); 31 ->getMock();
32 32
33 $wallabag = new ReadabilityImport($this->em, $this->contentProxy); 33 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
34 ->disableOriginalConstructor()
35 ->getMock();
36
37 $dispatcher
38 ->expects($this->exactly($dispatched))
39 ->method('dispatch');
40
41 $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $dispatcher);
34 42
35 $this->logHandler = new TestHandler(); 43 $this->logHandler = new TestHandler();
36 $logger = new Logger('test', [$this->logHandler]); 44 $logger = new Logger('test', [$this->logHandler]);
@@ -54,7 +62,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
54 62
55 public function testImport() 63 public function testImport()
56 { 64 {
57 $readabilityImport = $this->getReadabilityImport(); 65 $readabilityImport = $this->getReadabilityImport(false, 24);
58 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); 66 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json');
59 67
60 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 68 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -87,7 +95,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
87 95
88 public function testImportAndMarkAllAsRead() 96 public function testImportAndMarkAllAsRead()
89 { 97 {
90 $readabilityImport = $this->getReadabilityImport(); 98 $readabilityImport = $this->getReadabilityImport(false, 1);
91 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); 99 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability-read.json');
92 100
93 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 101 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
index 82dc4c7e..4dbced60 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
@@ -18,7 +18,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 20
21 private function getWallabagV1Import($unsetUser = false) 21 private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
22 { 22 {
23 $this->user = new User(); 23 $this->user = new User();
24 24
@@ -44,7 +44,15 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
44 ->disableOriginalConstructor() 44 ->disableOriginalConstructor()
45 ->getMock(); 45 ->getMock();
46 46
47 $wallabag = new WallabagV1Import($this->em, $this->contentProxy); 47 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
48 ->disableOriginalConstructor()
49 ->getMock();
50
51 $dispatcher
52 ->expects($this->exactly($dispatched))
53 ->method('dispatch');
54
55 $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $dispatcher);
48 56
49 $this->logHandler = new TestHandler(); 57 $this->logHandler = new TestHandler();
50 $logger = new Logger('test', [$this->logHandler]); 58 $logger = new Logger('test', [$this->logHandler]);
@@ -68,7 +76,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
68 76
69 public function testImport() 77 public function testImport()
70 { 78 {
71 $wallabagV1Import = $this->getWallabagV1Import(); 79 $wallabagV1Import = $this->getWallabagV1Import(false, 3);
72 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); 80 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
73 81
74 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 82 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -101,7 +109,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
101 109
102 public function testImportAndMarkAllAsRead() 110 public function testImportAndMarkAllAsRead()
103 { 111 {
104 $wallabagV1Import = $this->getWallabagV1Import(); 112 $wallabagV1Import = $this->getWallabagV1Import(false, 3);
105 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1-read.json'); 113 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1-read.json');
106 114
107 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 115 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
index bea89efb..0e50b8b2 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
@@ -18,7 +18,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 20
21 private function getWallabagV2Import($unsetUser = false) 21 private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
22 { 22 {
23 $this->user = new User(); 23 $this->user = new User();
24 24
@@ -44,7 +44,15 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
44 ->disableOriginalConstructor() 44 ->disableOriginalConstructor()
45 ->getMock(); 45 ->getMock();
46 46
47 $wallabag = new WallabagV2Import($this->em, $this->contentProxy); 47 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
48 ->disableOriginalConstructor()
49 ->getMock();
50
51 $dispatcher
52 ->expects($this->exactly($dispatched))
53 ->method('dispatch');
54
55 $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $dispatcher);
48 56
49 $this->logHandler = new TestHandler(); 57 $this->logHandler = new TestHandler();
50 $logger = new Logger('test', [$this->logHandler]); 58 $logger = new Logger('test', [$this->logHandler]);
@@ -68,7 +76,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
68 76
69 public function testImport() 77 public function testImport()
70 { 78 {
71 $wallabagV2Import = $this->getWallabagV2Import(); 79 $wallabagV2Import = $this->getWallabagV2Import(false, 2);
72 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); 80 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
73 81
74 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 82 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -97,7 +105,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
97 105
98 public function testImportAndMarkAllAsRead() 106 public function testImportAndMarkAllAsRead()
99 { 107 {
100 $wallabagV2Import = $this->getWallabagV2Import(); 108 $wallabagV2Import = $this->getWallabagV2Import(false, 2);
101 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-read.json'); 109 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-read.json');
102 110
103 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 111 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -246,7 +254,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
246 254
247 public function testImportWithExceptionFromGraby() 255 public function testImportWithExceptionFromGraby()
248 { 256 {
249 $wallabagV2Import = $this->getWallabagV2Import(); 257 $wallabagV2Import = $this->getWallabagV2Import(false, 2);
250 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); 258 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
251 259
252 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 260 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')