]>
Commit | Line | Data |
---|---|---|
93fd4692 NL |
1 | <?php |
2 | ||
ad4d1caa | 3 | namespace Wallabag\CoreBundle\Tests\Controller; |
93fd4692 | 4 | |
769e19dc | 5 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; |
2863bf2a | 6 | use Wallabag\CoreBundle\Entity\Entry; |
93fd4692 | 7 | |
769e19dc | 8 | class EntryControllerTest extends WallabagCoreTestCase |
93fd4692 | 9 | { |
02d17813 JB |
10 | public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html'; |
11 | ||
3b815d2d J |
12 | public function testLogin() |
13 | { | |
14 | $client = $this->getClient(); | |
15 | ||
eb3bd7ef | 16 | $client->request('GET', '/new'); |
3b815d2d J |
17 | |
18 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
19 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | |
20 | } | |
21 | ||
5c072d2b NL |
22 | public function testQuickstart() |
23 | { | |
24 | $this->logInAs('empty'); | |
25 | $client = $this->getClient(); | |
26 | ||
27 | $client->request('GET', '/unread/list'); | |
4f9cf232 | 28 | $crawler = $client->followRedirect(); |
5c072d2b NL |
29 | |
30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
4094ea47 | 31 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
4f9cf232 | 32 | $this->assertContains('quickstart.intro.paragraph_1', $body[0]); |
5c072d2b NL |
33 | |
34 | // Test if quickstart is disabled when user has 1 entry | |
35 | $crawler = $client->request('GET', '/new'); | |
36 | ||
37 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
38 | ||
0d42217e | 39 | $form = $crawler->filter('form[name=entry]')->form(); |
5c072d2b | 40 | |
4094ea47 | 41 | $data = [ |
78833672 | 42 | 'entry[url]' => $this->url, |
4094ea47 | 43 | ]; |
5c072d2b NL |
44 | |
45 | $client->submit($form, $data); | |
46 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
47 | $client->followRedirect(); | |
48 | ||
4f9cf232 | 49 | $crawler = $client->request('GET', '/unread/list'); |
4094ea47 | 50 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
4f9cf232 | 51 | $this->assertContains('entry.list.number_on_the_page', $body[0]); |
5c072d2b NL |
52 | } |
53 | ||
9c0c8820 | 54 | public function testGetNew() |
93fd4692 | 55 | { |
eb3bd7ef | 56 | $this->logInAs('admin'); |
3b815d2d | 57 | $client = $this->getClient(); |
93fd4692 | 58 | |
aa6e27cf | 59 | $crawler = $client->request('GET', '/new'); |
93fd4692 NL |
60 | |
61 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
9c0c8820 J |
62 | |
63 | $this->assertCount(1, $crawler->filter('input[type=url]')); | |
0d42217e | 64 | $this->assertCount(1, $crawler->filter('form[name=entry]')); |
9c0c8820 J |
65 | } |
66 | ||
880a0e1c NL |
67 | public function testPostNewViaBookmarklet() |
68 | { | |
69 | $this->logInAs('admin'); | |
70 | $client = $this->getClient(); | |
71 | ||
72 | $crawler = $client->request('GET', '/'); | |
73 | ||
74 | $this->assertCount(4, $crawler->filter('div[class=entry]')); | |
75 | ||
76 | // Good URL | |
4094ea47 | 77 | $client->request('GET', '/bookmarklet', ['url' => $this->url]); |
880a0e1c | 78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
5c072d2b | 79 | $client->followRedirect(); |
880a0e1c NL |
80 | $crawler = $client->request('GET', '/'); |
81 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | |
82 | ||
83 | $em = $client->getContainer() | |
84 | ->get('doctrine.orm.entity_manager'); | |
85 | $entry = $em | |
86 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 87 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
880a0e1c NL |
88 | $em->remove($entry); |
89 | $em->flush(); | |
90 | } | |
91 | ||
9c0c8820 J |
92 | public function testPostNewEmpty() |
93 | { | |
eb3bd7ef | 94 | $this->logInAs('admin'); |
3b815d2d | 95 | $client = $this->getClient(); |
9c0c8820 J |
96 | |
97 | $crawler = $client->request('GET', '/new'); | |
98 | ||
99 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
100 | ||
0d42217e | 101 | $form = $crawler->filter('form[name=entry]')->form(); |
9c0c8820 J |
102 | |
103 | $crawler = $client->submit($form); | |
104 | ||
105 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
4094ea47 | 106 | $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text'])); |
9c0c8820 J |
107 | $this->assertEquals('This value should not be blank.', $alert[0]); |
108 | } | |
109 | ||
8a493541 | 110 | /** |
75c48e3a | 111 | * This test will require an internet connection. |
8a493541 | 112 | */ |
9c0c8820 J |
113 | public function testPostNewOk() |
114 | { | |
eb3bd7ef | 115 | $this->logInAs('admin'); |
3b815d2d | 116 | $client = $this->getClient(); |
9c0c8820 J |
117 | |
118 | $crawler = $client->request('GET', '/new'); | |
119 | ||
120 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
121 | ||
0d42217e | 122 | $form = $crawler->filter('form[name=entry]')->form(); |
9c0c8820 | 123 | |
4094ea47 | 124 | $data = [ |
02d17813 | 125 | 'entry[url]' => $this->url, |
4094ea47 | 126 | ]; |
9c0c8820 J |
127 | |
128 | $client->submit($form, $data); | |
129 | ||
130 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
131 | ||
a0d6ccc5 JB |
132 | $content = $client->getContainer() |
133 | ->get('doctrine.orm.entity_manager') | |
134 | ->getRepository('WallabagCoreBundle:Entry') | |
135 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | |
136 | ||
137 | $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); | |
138 | $this->assertEquals($this->url, $content->getUrl()); | |
139 | $this->assertContains('Google', $content->getTitle()); | |
140 | } | |
9c0c8820 | 141 | |
a0d6ccc5 JB |
142 | public function testPostNewOkUrlExist() |
143 | { | |
144 | $this->logInAs('admin'); | |
145 | $client = $this->getClient(); | |
146 | ||
147 | $crawler = $client->request('GET', '/new'); | |
148 | ||
149 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
150 | ||
0d42217e | 151 | $form = $crawler->filter('form[name=entry]')->form(); |
a0d6ccc5 | 152 | |
4094ea47 | 153 | $data = [ |
a0d6ccc5 | 154 | 'entry[url]' => $this->url, |
4094ea47 | 155 | ]; |
a0d6ccc5 JB |
156 | |
157 | $client->submit($form, $data); | |
158 | ||
159 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
160 | $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); | |
9c0c8820 J |
161 | } |
162 | ||
958671a7 KG |
163 | /** |
164 | * This test will require an internet connection. | |
165 | */ | |
166 | public function testPostNewThatWillBeTaggued() | |
167 | { | |
168 | $this->logInAs('admin'); | |
169 | $client = $this->getClient(); | |
170 | ||
171 | $crawler = $client->request('GET', '/new'); | |
172 | ||
173 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
174 | ||
0d42217e | 175 | $form = $crawler->filter('form[name=entry]')->form(); |
958671a7 | 176 | |
4094ea47 | 177 | $data = [ |
958671a7 | 178 | 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', |
4094ea47 | 179 | ]; |
958671a7 KG |
180 | |
181 | $client->submit($form, $data); | |
182 | ||
183 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
184 | ||
5c072d2b | 185 | $client->followRedirect(); |
958671a7 KG |
186 | |
187 | $em = $client->getContainer() | |
188 | ->get('doctrine.orm.entity_manager'); | |
189 | $entry = $em | |
190 | ->getRepository('WallabagCoreBundle:Entry') | |
191 | ->findOneByUrl($url); | |
69edb774 KG |
192 | $tags = $entry->getTags(); |
193 | ||
194 | $this->assertCount(1, $tags); | |
195 | $this->assertEquals('wallabag', $tags[0]->getLabel()); | |
958671a7 KG |
196 | |
197 | $em->remove($entry); | |
198 | $em->flush(); | |
199 | } | |
200 | ||
9c0c8820 J |
201 | public function testArchive() |
202 | { | |
eb3bd7ef | 203 | $this->logInAs('admin'); |
3b815d2d | 204 | $client = $this->getClient(); |
9c0c8820 | 205 | |
9fb6ac83 | 206 | $client->request('GET', '/archive/list'); |
9c0c8820 J |
207 | |
208 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
209 | } | |
210 | ||
211 | public function testStarred() | |
212 | { | |
eb3bd7ef | 213 | $this->logInAs('admin'); |
3b815d2d | 214 | $client = $this->getClient(); |
9c0c8820 | 215 | |
9fb6ac83 | 216 | $client->request('GET', '/starred/list'); |
9c0c8820 J |
217 | |
218 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
219 | } | |
220 | ||
671a2b88 ML |
221 | public function testRangeException() |
222 | { | |
223 | $this->logInAs('admin'); | |
224 | $client = $this->getClient(); | |
225 | ||
226 | $client->request('GET', '/all/list/900'); | |
227 | ||
1880da74 NL |
228 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
229 | $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl()); | |
671a2b88 ML |
230 | } |
231 | ||
8a493541 JB |
232 | /** |
233 | * @depends testPostNewOk | |
234 | */ | |
9c0c8820 J |
235 | public function testView() |
236 | { | |
eb3bd7ef | 237 | $this->logInAs('admin'); |
3b815d2d | 238 | $client = $this->getClient(); |
9c0c8820 J |
239 | |
240 | $content = $client->getContainer() | |
241 | ->get('doctrine.orm.entity_manager') | |
242 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 243 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
9c0c8820 | 244 | |
4f9cf232 | 245 | $crawler = $client->request('GET', '/view/'.$content->getId()); |
9c0c8820 J |
246 | |
247 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
4094ea47 | 248 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); |
4f9cf232 | 249 | $this->assertContains($content->getTitle(), $body[0]); |
93fd4692 | 250 | } |
eb3bd7ef | 251 | |
831b02aa JB |
252 | /** |
253 | * @depends testPostNewOk | |
254 | * | |
255 | * This test will require an internet connection. | |
256 | */ | |
257 | public function testReload() | |
258 | { | |
259 | $this->logInAs('admin'); | |
260 | $client = $this->getClient(); | |
261 | ||
262 | $content = $client->getContainer() | |
263 | ->get('doctrine.orm.entity_manager') | |
264 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 265 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
831b02aa JB |
266 | |
267 | // empty content | |
268 | $content->setContent(''); | |
269 | $client->getContainer()->get('doctrine.orm.entity_manager')->persist($content); | |
270 | $client->getContainer()->get('doctrine.orm.entity_manager')->flush(); | |
271 | ||
272 | $client->request('GET', '/reload/'.$content->getId()); | |
273 | ||
274 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
275 | ||
276 | $content = $client->getContainer() | |
277 | ->get('doctrine.orm.entity_manager') | |
278 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 279 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
831b02aa JB |
280 | |
281 | $this->assertNotEmpty($content->getContent()); | |
282 | } | |
283 | ||
82d6d9cb JB |
284 | public function testEdit() |
285 | { | |
286 | $this->logInAs('admin'); | |
287 | $client = $this->getClient(); | |
288 | ||
289 | $content = $client->getContainer() | |
290 | ->get('doctrine.orm.entity_manager') | |
291 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 292 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
82d6d9cb JB |
293 | |
294 | $crawler = $client->request('GET', '/edit/'.$content->getId()); | |
295 | ||
296 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
297 | ||
298 | $this->assertCount(1, $crawler->filter('input[id=entry_title]')); | |
299 | $this->assertCount(1, $crawler->filter('button[id=entry_save]')); | |
300 | } | |
301 | ||
302 | public function testEditUpdate() | |
303 | { | |
304 | $this->logInAs('admin'); | |
305 | $client = $this->getClient(); | |
306 | ||
307 | $content = $client->getContainer() | |
308 | ->get('doctrine.orm.entity_manager') | |
309 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 310 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
82d6d9cb JB |
311 | |
312 | $crawler = $client->request('GET', '/edit/'.$content->getId()); | |
313 | ||
314 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
315 | ||
316 | $form = $crawler->filter('button[type=submit]')->form(); | |
317 | ||
4094ea47 | 318 | $data = [ |
82d6d9cb | 319 | 'entry[title]' => 'My updated title hehe :)', |
4094ea47 | 320 | ]; |
82d6d9cb JB |
321 | |
322 | $client->submit($form, $data); | |
323 | ||
324 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
325 | ||
326 | $crawler = $client->followRedirect(); | |
327 | ||
4094ea47 | 328 | $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); |
82d6d9cb JB |
329 | $this->assertContains('My updated title hehe :)', $alert[0]); |
330 | } | |
331 | ||
eb3bd7ef J |
332 | public function testToggleArchive() |
333 | { | |
334 | $this->logInAs('admin'); | |
335 | $client = $this->getClient(); | |
336 | ||
337 | $content = $client->getContainer() | |
338 | ->get('doctrine.orm.entity_manager') | |
339 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 340 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
eb3bd7ef J |
341 | |
342 | $client->request('GET', '/archive/'.$content->getId()); | |
343 | ||
344 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
345 | ||
346 | $res = $client->getContainer() | |
347 | ->get('doctrine.orm.entity_manager') | |
348 | ->getRepository('WallabagCoreBundle:Entry') | |
159986c4 | 349 | ->find($content->getId()); |
eb3bd7ef J |
350 | |
351 | $this->assertEquals($res->isArchived(), true); | |
352 | } | |
353 | ||
354 | public function testToggleStar() | |
355 | { | |
356 | $this->logInAs('admin'); | |
357 | $client = $this->getClient(); | |
358 | ||
359 | $content = $client->getContainer() | |
360 | ->get('doctrine.orm.entity_manager') | |
361 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 362 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
eb3bd7ef J |
363 | |
364 | $client->request('GET', '/star/'.$content->getId()); | |
365 | ||
366 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
367 | ||
368 | $res = $client->getContainer() | |
369 | ->get('doctrine.orm.entity_manager') | |
370 | ->getRepository('WallabagCoreBundle:Entry') | |
371 | ->findOneById($content->getId()); | |
372 | ||
373 | $this->assertEquals($res->isStarred(), true); | |
374 | } | |
375 | ||
376 | public function testDelete() | |
377 | { | |
378 | $this->logInAs('admin'); | |
379 | $client = $this->getClient(); | |
380 | ||
381 | $content = $client->getContainer() | |
382 | ->get('doctrine.orm.entity_manager') | |
383 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 384 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
eb3bd7ef J |
385 | |
386 | $client->request('GET', '/delete/'.$content->getId()); | |
387 | ||
388 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
389 | ||
1d147791 | 390 | $client->request('GET', '/delete/'.$content->getId()); |
eb3bd7ef | 391 | |
1d147791 | 392 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
eb3bd7ef | 393 | } |
3d2b2d62 | 394 | |
2863bf2a JB |
395 | /** |
396 | * It will create a new entry. | |
397 | * Browse to it. | |
398 | * Then remove it. | |
399 | * | |
400 | * And it'll check that user won't be redirected to the view page of the content when it had been removed | |
401 | */ | |
402 | public function testViewAndDelete() | |
403 | { | |
404 | $this->logInAs('admin'); | |
405 | $client = $this->getClient(); | |
406 | ||
407 | // add a new content to be removed later | |
408 | $user = $client->getContainer() | |
409 | ->get('doctrine.orm.entity_manager') | |
410 | ->getRepository('WallabagUserBundle:User') | |
411 | ->findOneByUserName('admin'); | |
412 | ||
413 | $content = new Entry($user); | |
414 | $content->setUrl('http://1.1.1.1/entry'); | |
415 | $content->setReadingTime(12); | |
416 | $content->setDomainName('domain.io'); | |
417 | $content->setMimetype('text/html'); | |
418 | $content->setTitle('test title entry'); | |
419 | $content->setContent('This is my content /o/'); | |
420 | $content->setArchived(true); | |
421 | $content->setLanguage('fr'); | |
422 | ||
423 | $client->getContainer() | |
424 | ->get('doctrine.orm.entity_manager') | |
425 | ->persist($content); | |
426 | $client->getContainer() | |
427 | ->get('doctrine.orm.entity_manager') | |
428 | ->flush(); | |
429 | ||
430 | $client->request('GET', '/view/'.$content->getId()); | |
431 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
432 | ||
433 | $client->request('GET', '/delete/'.$content->getId()); | |
434 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
435 | ||
436 | $client->followRedirect(); | |
437 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
438 | } | |
439 | ||
3d2b2d62 J |
440 | public function testViewOtherUserEntry() |
441 | { | |
159986c4 | 442 | $this->logInAs('admin'); |
3d2b2d62 J |
443 | $client = $this->getClient(); |
444 | ||
445 | $content = $client->getContainer() | |
446 | ->get('doctrine.orm.entity_manager') | |
447 | ->getRepository('WallabagCoreBundle:Entry') | |
159986c4 | 448 | ->findOneByUsernameAndNotArchived('bob'); |
3d2b2d62 | 449 | |
159986c4 | 450 | $client->request('GET', '/view/'.$content->getId()); |
3d2b2d62 J |
451 | |
452 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | |
453 | } | |
26864574 | 454 | |
3f357ee2 | 455 | public function testFilterOnReadingTime() |
26864574 NL |
456 | { |
457 | $this->logInAs('admin'); | |
458 | $client = $this->getClient(); | |
459 | ||
460 | $crawler = $client->request('GET', '/unread/list'); | |
461 | ||
462 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
463 | ||
4094ea47 | 464 | $data = [ |
d6a9e139 NL |
465 | 'entry_filter[readingTime][right_number]' => 22, |
466 | 'entry_filter[readingTime][left_number]' => 22, | |
4094ea47 | 467 | ]; |
26864574 NL |
468 | |
469 | $crawler = $client->submit($form, $data); | |
470 | ||
471 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | |
472 | } | |
ab2c93c7 | 473 | |
3f357ee2 NL |
474 | public function testFilterOnCreationDate() |
475 | { | |
476 | $this->logInAs('admin'); | |
477 | $client = $this->getClient(); | |
478 | ||
479 | $crawler = $client->request('GET', '/unread/list'); | |
480 | ||
481 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
482 | ||
4094ea47 | 483 | $data = [ |
3f357ee2 | 484 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), |
8ce32af6 | 485 | 'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')), |
4094ea47 | 486 | ]; |
3f357ee2 NL |
487 | |
488 | $crawler = $client->submit($form, $data); | |
489 | ||
e1779760 | 490 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
3f357ee2 | 491 | |
4094ea47 | 492 | $data = [ |
f90af145 JB |
493 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), |
494 | 'entry_filter[createdAt][right_date]' => date('d/m/Y'), | |
4094ea47 | 495 | ]; |
f90af145 JB |
496 | |
497 | $crawler = $client->submit($form, $data); | |
498 | ||
499 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | |
500 | ||
4094ea47 | 501 | $data = [ |
3f357ee2 | 502 | 'entry_filter[createdAt][left_date]' => '01/01/1970', |
8ce32af6 | 503 | 'entry_filter[createdAt][right_date]' => '01/01/1970', |
4094ea47 | 504 | ]; |
3f357ee2 NL |
505 | |
506 | $crawler = $client->submit($form, $data); | |
507 | ||
508 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | |
3f357ee2 NL |
509 | } |
510 | ||
ab2c93c7 NL |
511 | public function testPaginationWithFilter() |
512 | { | |
513 | $this->logInAs('admin'); | |
514 | $client = $this->getClient(); | |
ab2c93c7 NL |
515 | $crawler = $client->request('GET', '/config'); |
516 | ||
517 | $form = $crawler->filter('button[id=config_save]')->form(); | |
518 | ||
4094ea47 | 519 | $data = [ |
ab2c93c7 | 520 | 'config[items_per_page]' => '1', |
4094ea47 | 521 | ]; |
ab2c93c7 NL |
522 | |
523 | $client->submit($form, $data); | |
524 | ||
76cd8dbb | 525 | $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; |
ab2c93c7 | 526 | |
5c072d2b | 527 | $client->request('GET', 'unread/list'.$parameters); |
ab2c93c7 NL |
528 | |
529 | $this->assertContains($parameters, $client->getResponse()->getContent()); | |
e1779760 NL |
530 | |
531 | // reset pagination | |
532 | $crawler = $client->request('GET', '/config'); | |
533 | $form = $crawler->filter('button[id=config_save]')->form(); | |
4094ea47 | 534 | $data = [ |
e1779760 | 535 | 'config[items_per_page]' => '12', |
4094ea47 | 536 | ]; |
e1779760 | 537 | $client->submit($form, $data); |
ab2c93c7 | 538 | } |
443cecd2 NL |
539 | |
540 | public function testFilterOnDomainName() | |
541 | { | |
542 | $this->logInAs('admin'); | |
543 | $client = $this->getClient(); | |
544 | ||
545 | $crawler = $client->request('GET', '/unread/list'); | |
546 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
4094ea47 | 547 | $data = [ |
02d17813 | 548 | 'entry_filter[domainName]' => 'domain', |
4094ea47 | 549 | ]; |
443cecd2 NL |
550 | |
551 | $crawler = $client->submit($form, $data); | |
02d17813 | 552 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
443cecd2 NL |
553 | |
554 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
4094ea47 | 555 | $data = [ |
8ce32af6 | 556 | 'entry_filter[domainName]' => 'wallabag', |
4094ea47 | 557 | ]; |
443cecd2 NL |
558 | |
559 | $crawler = $client->submit($form, $data); | |
560 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | |
561 | } | |
e1779760 NL |
562 | |
563 | public function testFilterOnStatus() | |
564 | { | |
565 | $this->logInAs('admin'); | |
566 | $client = $this->getClient(); | |
567 | ||
568 | $crawler = $client->request('GET', '/unread/list'); | |
569 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
570 | $form['entry_filter[isArchived]']->tick(); | |
571 | $form['entry_filter[isStarred]']->untick(); | |
572 | ||
573 | $crawler = $client->submit($form); | |
159986c4 | 574 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
e1779760 NL |
575 | |
576 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
577 | $form['entry_filter[isArchived]']->untick(); | |
578 | $form['entry_filter[isStarred]']->tick(); | |
579 | ||
580 | $crawler = $client->submit($form); | |
02d17813 | 581 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
e1779760 | 582 | } |
497e0cad NL |
583 | |
584 | public function testPreviewPictureFilter() | |
585 | { | |
586 | $this->logInAs('admin'); | |
587 | $client = $this->getClient(); | |
588 | ||
589 | $crawler = $client->request('GET', '/unread/list'); | |
590 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
591 | $form['entry_filter[previewPicture]']->tick(); | |
592 | ||
593 | $crawler = $client->submit($form); | |
594 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | |
595 | } | |
d4ebe5c5 JB |
596 | |
597 | public function testFilterOnLanguage() | |
598 | { | |
599 | $this->logInAs('admin'); | |
600 | $client = $this->getClient(); | |
601 | ||
602 | $crawler = $client->request('GET', '/unread/list'); | |
603 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
4094ea47 | 604 | $data = [ |
159986c4 | 605 | 'entry_filter[language]' => 'fr', |
4094ea47 | 606 | ]; |
d4ebe5c5 JB |
607 | |
608 | $crawler = $client->submit($form, $data); | |
02d17813 | 609 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
d4ebe5c5 JB |
610 | |
611 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
4094ea47 | 612 | $data = [ |
d4ebe5c5 | 613 | 'entry_filter[language]' => 'en', |
4094ea47 | 614 | ]; |
d4ebe5c5 JB |
615 | |
616 | $crawler = $client->submit($form, $data); | |
617 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | |
618 | } | |
93fd4692 | 619 | } |