diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2017-01-27 09:34:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-27 09:34:32 +0100 |
commit | 6fb06904ecde15b1b07d0a2af945338b416cf0e2 (patch) | |
tree | e76f3e8142399316ec5660fab8c646b2c34b8336 /tests/Wallabag/ImportBundle | |
parent | 05fa529bcfde01be5d320cb532900d72cf4b0830 (diff) | |
parent | 78295b99dd1721c613f1ce52e2debbe6f6db7753 (diff) | |
download | wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.gz wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.zst wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.zip |
Merge pull request #2416 from wallabag/2.2
wallabag 2.2.0
Diffstat (limited to 'tests/Wallabag/ImportBundle')
18 files changed, 375 insertions, 66 deletions
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/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index c0417bbe..c1f82ea9 100644 --- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | |||
@@ -118,8 +118,8 @@ class ChromeControllerTest extends WallabagCoreTestCase | |||
118 | $this->getLoggedInUserId() | 118 | $this->getLoggedInUserId() |
119 | ); | 119 | ); |
120 | 120 | ||
121 | $this->assertNotEmpty($content->getPreviewPicture()); | 121 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); |
122 | $this->assertNotEmpty($content->getLanguage()); | 122 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); |
123 | $this->assertEquals(0, count($content->getTags())); | 123 | $this->assertEquals(0, count($content->getTags())); |
124 | 124 | ||
125 | $createdAt = $content->getCreatedAt(); | 125 | $createdAt = $content->getCreatedAt(); |
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php index 6154ae8d..7557ea32 100644 --- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php | |||
@@ -118,9 +118,9 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
118 | $this->getLoggedInUserId() | 118 | $this->getLoggedInUserId() |
119 | ); | 119 | ); |
120 | 120 | ||
121 | $this->assertNotEmpty($content->getMimetype()); | 121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture()); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); |
123 | $this->assertNotEmpty($content->getLanguage()); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); |
124 | $this->assertEquals(2, count($content->getTags())); | 124 | $this->assertEquals(2, count($content->getTags())); |
125 | 125 | ||
126 | $content = $client->getContainer() | 126 | $content = $client->getContainer() |
@@ -131,9 +131,9 @@ class FirefoxControllerTest extends WallabagCoreTestCase | |||
131 | $this->getLoggedInUserId() | 131 | $this->getLoggedInUserId() |
132 | ); | 132 | ); |
133 | 133 | ||
134 | $this->assertNotEmpty($content->getMimetype()); | 134 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://stackoverflow.com is ok'); |
135 | $this->assertNotEmpty($content->getPreviewPicture()); | 135 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://stackoverflow.com is ok'); |
136 | $this->assertEmpty($content->getLanguage()); | 136 | $this->assertEmpty($content->getLanguage(), 'Language for http://stackoverflow.com is ok'); |
137 | 137 | ||
138 | $createdAt = $content->getCreatedAt(); | 138 | $createdAt = $content->getCreatedAt(); |
139 | $this->assertEquals('2013', $createdAt->format('Y')); | 139 | $this->assertEquals('2013', $createdAt->format('Y')); |
diff --git a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php index 0bc40bdd..5e57dcef 100644 --- a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php | |||
@@ -24,6 +24,6 @@ class ImportControllerTest extends WallabagCoreTestCase | |||
24 | $crawler = $client->request('GET', '/import/'); | 24 | $crawler = $client->request('GET', '/import/'); |
25 | 25 | ||
26 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 26 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
27 | $this->assertEquals(7, $crawler->filter('blockquote')->count()); | 27 | $this->assertEquals(8, $crawler->filter('blockquote')->count()); |
28 | } | 28 | } |
29 | } | 29 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php index 9df08e75..3f6f2b9f 100644 --- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php | |||
@@ -118,9 +118,9 @@ class InstapaperControllerTest extends WallabagCoreTestCase | |||
118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
119 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 119 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
120 | 120 | ||
121 | $this->assertNotEmpty($content->getMimetype()); | 121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture()); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); |
123 | $this->assertNotEmpty($content->getLanguage()); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); |
124 | $this->assertEquals(0, count($content->getTags())); | 124 | $this->assertEquals(0, count($content->getTags())); |
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
126 | } | 126 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php new file mode 100644 index 00000000..75a7e332 --- /dev/null +++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php | |||
@@ -0,0 +1,197 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Tests\Wallabag\ImportBundle\Controller; | ||
4 | |||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
6 | use Symfony\Component\HttpFoundation\File\UploadedFile; | ||
7 | |||
8 | class PinboardControllerTest extends WallabagCoreTestCase | ||
9 | { | ||
10 | public function testImportPinboard() | ||
11 | { | ||
12 | $this->logInAs('admin'); | ||
13 | $client = $this->getClient(); | ||
14 | |||
15 | $crawler = $client->request('GET', '/import/pinboard'); | ||
16 | |||
17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
18 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
19 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
20 | } | ||
21 | |||
22 | public function testImportPinboardWithRabbitEnabled() | ||
23 | { | ||
24 | $this->logInAs('admin'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 1); | ||
28 | |||
29 | $crawler = $client->request('GET', '/import/pinboard'); | ||
30 | |||
31 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
32 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
33 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
34 | |||
35 | $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); | ||
36 | } | ||
37 | |||
38 | public function testImportPinboardBadFile() | ||
39 | { | ||
40 | $this->logInAs('admin'); | ||
41 | $client = $this->getClient(); | ||
42 | |||
43 | $crawler = $client->request('GET', '/import/pinboard'); | ||
44 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
45 | |||
46 | $data = [ | ||
47 | 'upload_import_file[file]' => '', | ||
48 | ]; | ||
49 | |||
50 | $client->submit($form, $data); | ||
51 | |||
52 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
53 | } | ||
54 | |||
55 | public function testImportPinboardWithRedisEnabled() | ||
56 | { | ||
57 | $this->checkRedis(); | ||
58 | $this->logInAs('admin'); | ||
59 | $client = $this->getClient(); | ||
60 | $client->getContainer()->get('craue_config')->set('import_with_redis', 1); | ||
61 | |||
62 | $crawler = $client->request('GET', '/import/pinboard'); | ||
63 | |||
64 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
65 | $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); | ||
66 | $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); | ||
67 | |||
68 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
69 | |||
70 | $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json'); | ||
71 | |||
72 | $data = [ | ||
73 | 'upload_import_file[file]' => $file, | ||
74 | ]; | ||
75 | |||
76 | $client->submit($form, $data); | ||
77 | |||
78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
79 | |||
80 | $crawler = $client->followRedirect(); | ||
81 | |||
82 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
83 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
84 | |||
85 | $this->assertNotEmpty($client->getContainer()->get('wallabag_core.redis.client')->lpop('wallabag.import.pinboard')); | ||
86 | |||
87 | $client->getContainer()->get('craue_config')->set('import_with_redis', 0); | ||
88 | } | ||
89 | |||
90 | public function testImportPinboardWithFile() | ||
91 | { | ||
92 | $this->logInAs('admin'); | ||
93 | $client = $this->getClient(); | ||
94 | |||
95 | $crawler = $client->request('GET', '/import/pinboard'); | ||
96 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
97 | |||
98 | $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json'); | ||
99 | |||
100 | $data = [ | ||
101 | 'upload_import_file[file]' => $file, | ||
102 | ]; | ||
103 | |||
104 | $client->submit($form, $data); | ||
105 | |||
106 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
107 | |||
108 | $crawler = $client->followRedirect(); | ||
109 | |||
110 | $content = $client->getContainer() | ||
111 | ->get('doctrine.orm.entity_manager') | ||
112 | ->getRepository('WallabagCoreBundle:Entry') | ||
113 | ->findByUrlAndUserId( | ||
114 | 'https://ma.ttias.be/varnish-explained/', | ||
115 | $this->getLoggedInUserId() | ||
116 | ); | ||
117 | |||
118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
119 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
120 | |||
121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok'); | ||
122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok'); | ||
123 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok'); | ||
124 | $this->assertEquals(2, count($content->getTags())); | ||
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | ||
126 | $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); | ||
127 | } | ||
128 | |||
129 | public function testImportPinboardWithFileAndMarkAllAsRead() | ||
130 | { | ||
131 | $this->logInAs('admin'); | ||
132 | $client = $this->getClient(); | ||
133 | |||
134 | $crawler = $client->request('GET', '/import/pinboard'); | ||
135 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
136 | |||
137 | $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard-read.json'); | ||
138 | |||
139 | $data = [ | ||
140 | 'upload_import_file[file]' => $file, | ||
141 | 'upload_import_file[mark_as_read]' => 1, | ||
142 | ]; | ||
143 | |||
144 | $client->submit($form, $data); | ||
145 | |||
146 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
147 | |||
148 | $crawler = $client->followRedirect(); | ||
149 | |||
150 | $content1 = $client->getContainer() | ||
151 | ->get('doctrine.orm.entity_manager') | ||
152 | ->getRepository('WallabagCoreBundle:Entry') | ||
153 | ->findByUrlAndUserId( | ||
154 | 'https://ilia.ws/files/nginx_torontophpug.pdf', | ||
155 | $this->getLoggedInUserId() | ||
156 | ); | ||
157 | |||
158 | $this->assertTrue($content1->isArchived()); | ||
159 | |||
160 | $content2 = $client->getContainer() | ||
161 | ->get('doctrine.orm.entity_manager') | ||
162 | ->getRepository('WallabagCoreBundle:Entry') | ||
163 | ->findByUrlAndUserId( | ||
164 | 'https://developers.google.com/web/updates/2016/07/infinite-scroller', | ||
165 | $this->getLoggedInUserId() | ||
166 | ); | ||
167 | |||
168 | $this->assertTrue($content2->isArchived()); | ||
169 | |||
170 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
171 | $this->assertContains('flashes.import.notice.summary', $body[0]); | ||
172 | } | ||
173 | |||
174 | public function testImportPinboardWithEmptyFile() | ||
175 | { | ||
176 | $this->logInAs('admin'); | ||
177 | $client = $this->getClient(); | ||
178 | |||
179 | $crawler = $client->request('GET', '/import/pinboard'); | ||
180 | $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); | ||
181 | |||
182 | $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); | ||
183 | |||
184 | $data = [ | ||
185 | 'upload_import_file[file]' => $file, | ||
186 | ]; | ||
187 | |||
188 | $client->submit($form, $data); | ||
189 | |||
190 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
191 | |||
192 | $crawler = $client->followRedirect(); | ||
193 | |||
194 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
195 | $this->assertContains('flashes.import.notice.failed', $body[0]); | ||
196 | } | ||
197 | } | ||
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php index 916dd297..acb61ca1 100644 --- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php | |||
@@ -111,19 +111,19 @@ class ReadabilityControllerTest extends WallabagCoreTestCase | |||
111 | ->get('doctrine.orm.entity_manager') | 111 | ->get('doctrine.orm.entity_manager') |
112 | ->getRepository('WallabagCoreBundle:Entry') | 112 | ->getRepository('WallabagCoreBundle:Entry') |
113 | ->findByUrlAndUserId( | 113 | ->findByUrlAndUserId( |
114 | 'https://venngage.com/blog/hashtags-are-worthless/', | 114 | 'http://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/', |
115 | $this->getLoggedInUserId() | 115 | $this->getLoggedInUserId() |
116 | ); | 116 | ); |
117 | 117 | ||
118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 118 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
119 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 119 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
120 | 120 | ||
121 | $this->assertNotEmpty($content->getMimetype()); | 121 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); |
122 | $this->assertNotEmpty($content->getPreviewPicture()); | 122 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); |
123 | $this->assertNotEmpty($content->getLanguage()); | 123 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); |
124 | $this->assertEquals(0, count($content->getTags())); | 124 | $this->assertEquals(0, count($content->getTags())); |
125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 125 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
126 | $this->assertEquals('2016-08-25', $content->getCreatedAt()->format('Y-m-d')); | 126 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
127 | } | 127 | } |
128 | 128 | ||
129 | public function testImportReadabilityWithFileAndMarkAllAsRead() | 129 | public function testImportReadabilityWithFileAndMarkAllAsRead() |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php index 3497c4b8..acc39997 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php | |||
@@ -112,7 +112,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
112 | ->get('doctrine.orm.entity_manager') | 112 | ->get('doctrine.orm.entity_manager') |
113 | ->getRepository('WallabagCoreBundle:Entry') | 113 | ->getRepository('WallabagCoreBundle:Entry') |
114 | ->findByUrlAndUserId( | 114 | ->findByUrlAndUserId( |
115 | 'http://www.framablog.org/index.php/post/2014/02/05/Framabag-service-libre-gratuit-interview-developpeur', | 115 | 'https://framablog.org/2014/02/05/framabag-service-libre-gratuit-interview-developpeur/', |
116 | $this->getLoggedInUserId() | 116 | $this->getLoggedInUserId() |
117 | ); | 117 | ); |
118 | 118 | ||
@@ -126,9 +126,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase | |||
126 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | 126 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
127 | $this->assertContains('flashes.import.notice.summary', $body[0]); | 127 | $this->assertContains('flashes.import.notice.summary', $body[0]); |
128 | 128 | ||
129 | $this->assertEmpty($content->getMimetype()); | 129 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); |
130 | $this->assertEmpty($content->getPreviewPicture()); | 130 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); |
131 | $this->assertEmpty($content->getLanguage()); | 131 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); |
132 | $this->assertEquals(1, count($content->getTags())); | 132 | $this->assertEquals(1, count($content->getTags())); |
133 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 133 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
134 | } | 134 | } |
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php index 27d2d52b..26e2f40b 100644 --- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php | |||
@@ -119,9 +119,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
119 | $this->getLoggedInUserId() | 119 | $this->getLoggedInUserId() |
120 | ); | 120 | ); |
121 | 121 | ||
122 | $this->assertNotEmpty($content->getMimetype()); | 122 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); |
123 | $this->assertNotEmpty($content->getPreviewPicture()); | 123 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); |
124 | $this->assertNotEmpty($content->getLanguage()); | 124 | $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); |
125 | $this->assertEquals(0, count($content->getTags())); | 125 | $this->assertEquals(0, count($content->getTags())); |
126 | 126 | ||
127 | $content = $client->getContainer() | 127 | $content = $client->getContainer() |
@@ -132,9 +132,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase | |||
132 | $this->getLoggedInUserId() | 132 | $this->getLoggedInUserId() |
133 | ); | 133 | ); |
134 | 134 | ||
135 | $this->assertNotEmpty($content->getMimetype()); | 135 | $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok'); |
136 | $this->assertNotEmpty($content->getPreviewPicture()); | 136 | $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok'); |
137 | $this->assertNotEmpty($content->getLanguage()); | 137 | $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok'); |
138 | $this->assertEquals(2, count($content->getTags())); | 138 | $this->assertEquals(2, count($content->getTags())); |
139 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); | 139 | $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); |
140 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); | 140 | $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); |
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') |
diff --git a/tests/Wallabag/ImportBundle/fixtures/pinboard_export b/tests/Wallabag/ImportBundle/fixtures/pinboard_export new file mode 100644 index 00000000..2dd744d3 --- /dev/null +++ b/tests/Wallabag/ImportBundle/fixtures/pinboard_export | |||
@@ -0,0 +1,5 @@ | |||
1 | [{"href":"https:\/\/developers.google.com\/web\/updates\/2016\/07\/infinite-scroller","description":"Complexities of an Infinite Scroller","extended":"TL;DR: Re-use your DOM elements and remove the ones that are far away from the viewport. Use placeholders to account for delayed data","meta":"21ff61c6f648901168f9e6119f53df7d","hash":"e69b65724cca1c585b446d4c47865d76","time":"2016-10-31T15:57:56Z","shared":"yes","toread":"no","tags":"infinite dom performance scroll"}, | ||
2 | {"href":"https:\/\/ma.ttias.be\/varnish-explained\/","description":"Varnish (explained) for PHP developers","extended":"A few months ago, I gave a presentation at LaraconEU in Amsterdam titled \"Varnish for PHP developers\". The generic title of that presentation is actually Varnish Explained and this is a write-up of that presentation, the video and the slides.","meta":"d32ad9fac2ed29da4aec12c562e9afb1","hash":"21dd6bdda8ad62666a2c9e79f6e80f98","time":"2016-10-26T06:43:03Z","shared":"yes","toread":"no","tags":"varnish PHP"}, | ||
3 | {"href":"https:\/\/ilia.ws\/files\/nginx_torontophpug.pdf","description":"Nginx Tricks for PHP Developers","extended":"","meta":"9adbb5c4ca6760e335b920800d88c70a","hash":"0189bb08f8bd0122c6544bed4624c546","time":"2016-10-05T07:11:27Z","shared":"yes","toread":"no","tags":"nginx PHP best_practice"}, | ||
4 | {"href":"https:\/\/jolicode.com\/blog\/starting-a-mobile-application-with-react-native","description":"Starting a mobile application with React Native","extended":"While preparing our next React Native training, I learnt a lot on the library and discovered an amazing community with a lot of packages.","meta":"bd140bd3e53e3a0b4cb08cdaf64bcbfc","hash":"015fa10cd97f56186420555e52cfab62","time":"2016-09-23T10:58:20Z","shared":"yes","toread":"no","tags":"react-native"}, | ||
5 | {"href":"http:\/\/open.blogs.nytimes.com\/2016\/08\/29\/testing-varnish-using-varnishtest\/","description":"Testing Varnish Using Varnishtest","extended":"Varnish ships with the ability to test using the testing tool varnishtest. Varnishtest gives you the ability to write VCL tests you can run on the command line or as part of your build process.","meta":"ca2752a07adea4bab52cd19e8fdbf356","hash":"d3e642cc1274d10e4c12ee31f5dde736","time":"2016-08-30T09:33:24Z","shared":"yes","toread":"no","tags":"varnish test vcl"}] | ||