]>
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()); | |
4f9cf232 JB |
31 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
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 NL |
40 | |
41 | $data = array( | |
78833672 | 42 | 'entry[url]' => $this->url, |
5c072d2b NL |
43 | ); |
44 | ||
45 | $client->submit($form, $data); | |
46 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
47 | $client->followRedirect(); | |
48 | ||
4f9cf232 JB |
49 | $crawler = $client->request('GET', '/unread/list'); |
50 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); | |
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 | |
5c072d2b | 77 | $client->request('GET', '/bookmarklet', array('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()); | |
106 | $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(array('_text'))); | |
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 J |
123 | |
124 | $data = array( | |
02d17813 | 125 | 'entry[url]' => $this->url, |
9c0c8820 J |
126 | ); |
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 JB |
152 | |
153 | $data = array( | |
154 | 'entry[url]' => $this->url, | |
155 | ); | |
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 KG |
176 | |
177 | $data = array( | |
178 | 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', | |
179 | ); | |
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 | ||
624a7c6d | 228 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
671a2b88 ML |
229 | } |
230 | ||
8a493541 JB |
231 | /** |
232 | * @depends testPostNewOk | |
233 | */ | |
9c0c8820 J |
234 | public function testView() |
235 | { | |
eb3bd7ef | 236 | $this->logInAs('admin'); |
3b815d2d | 237 | $client = $this->getClient(); |
9c0c8820 J |
238 | |
239 | $content = $client->getContainer() | |
240 | ->get('doctrine.orm.entity_manager') | |
241 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 242 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
9c0c8820 | 243 | |
4f9cf232 | 244 | $crawler = $client->request('GET', '/view/'.$content->getId()); |
9c0c8820 J |
245 | |
246 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
4f9cf232 JB |
247 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
248 | $this->assertContains($content->getTitle(), $body[0]); | |
93fd4692 | 249 | } |
eb3bd7ef | 250 | |
831b02aa JB |
251 | /** |
252 | * @depends testPostNewOk | |
253 | * | |
254 | * This test will require an internet connection. | |
255 | */ | |
256 | public function testReload() | |
257 | { | |
258 | $this->logInAs('admin'); | |
259 | $client = $this->getClient(); | |
260 | ||
261 | $content = $client->getContainer() | |
262 | ->get('doctrine.orm.entity_manager') | |
263 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 264 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
831b02aa JB |
265 | |
266 | // empty content | |
267 | $content->setContent(''); | |
268 | $client->getContainer()->get('doctrine.orm.entity_manager')->persist($content); | |
269 | $client->getContainer()->get('doctrine.orm.entity_manager')->flush(); | |
270 | ||
271 | $client->request('GET', '/reload/'.$content->getId()); | |
272 | ||
273 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
274 | ||
275 | $content = $client->getContainer() | |
276 | ->get('doctrine.orm.entity_manager') | |
277 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 278 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
831b02aa JB |
279 | |
280 | $this->assertNotEmpty($content->getContent()); | |
281 | } | |
282 | ||
82d6d9cb JB |
283 | public function testEdit() |
284 | { | |
285 | $this->logInAs('admin'); | |
286 | $client = $this->getClient(); | |
287 | ||
288 | $content = $client->getContainer() | |
289 | ->get('doctrine.orm.entity_manager') | |
290 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 291 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
82d6d9cb JB |
292 | |
293 | $crawler = $client->request('GET', '/edit/'.$content->getId()); | |
294 | ||
295 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
296 | ||
297 | $this->assertCount(1, $crawler->filter('input[id=entry_title]')); | |
298 | $this->assertCount(1, $crawler->filter('button[id=entry_save]')); | |
299 | } | |
300 | ||
301 | public function testEditUpdate() | |
302 | { | |
303 | $this->logInAs('admin'); | |
304 | $client = $this->getClient(); | |
305 | ||
306 | $content = $client->getContainer() | |
307 | ->get('doctrine.orm.entity_manager') | |
308 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 309 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
82d6d9cb JB |
310 | |
311 | $crawler = $client->request('GET', '/edit/'.$content->getId()); | |
312 | ||
313 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
314 | ||
315 | $form = $crawler->filter('button[type=submit]')->form(); | |
316 | ||
317 | $data = array( | |
318 | 'entry[title]' => 'My updated title hehe :)', | |
319 | ); | |
320 | ||
321 | $client->submit($form, $data); | |
322 | ||
323 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
324 | ||
325 | $crawler = $client->followRedirect(); | |
326 | ||
327 | $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(array('_text'))); | |
328 | $this->assertContains('My updated title hehe :)', $alert[0]); | |
329 | } | |
330 | ||
eb3bd7ef J |
331 | public function testToggleArchive() |
332 | { | |
333 | $this->logInAs('admin'); | |
334 | $client = $this->getClient(); | |
335 | ||
336 | $content = $client->getContainer() | |
337 | ->get('doctrine.orm.entity_manager') | |
338 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 339 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
eb3bd7ef J |
340 | |
341 | $client->request('GET', '/archive/'.$content->getId()); | |
342 | ||
343 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
344 | ||
345 | $res = $client->getContainer() | |
346 | ->get('doctrine.orm.entity_manager') | |
347 | ->getRepository('WallabagCoreBundle:Entry') | |
159986c4 | 348 | ->find($content->getId()); |
eb3bd7ef J |
349 | |
350 | $this->assertEquals($res->isArchived(), true); | |
351 | } | |
352 | ||
353 | public function testToggleStar() | |
354 | { | |
355 | $this->logInAs('admin'); | |
356 | $client = $this->getClient(); | |
357 | ||
358 | $content = $client->getContainer() | |
359 | ->get('doctrine.orm.entity_manager') | |
360 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 361 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
eb3bd7ef J |
362 | |
363 | $client->request('GET', '/star/'.$content->getId()); | |
364 | ||
365 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
366 | ||
367 | $res = $client->getContainer() | |
368 | ->get('doctrine.orm.entity_manager') | |
369 | ->getRepository('WallabagCoreBundle:Entry') | |
370 | ->findOneById($content->getId()); | |
371 | ||
372 | $this->assertEquals($res->isStarred(), true); | |
373 | } | |
374 | ||
375 | public function testDelete() | |
376 | { | |
377 | $this->logInAs('admin'); | |
378 | $client = $this->getClient(); | |
379 | ||
380 | $content = $client->getContainer() | |
381 | ->get('doctrine.orm.entity_manager') | |
382 | ->getRepository('WallabagCoreBundle:Entry') | |
78833672 | 383 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
eb3bd7ef J |
384 | |
385 | $client->request('GET', '/delete/'.$content->getId()); | |
386 | ||
387 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
388 | ||
1d147791 | 389 | $client->request('GET', '/delete/'.$content->getId()); |
eb3bd7ef | 390 | |
1d147791 | 391 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); |
eb3bd7ef | 392 | } |
3d2b2d62 | 393 | |
2863bf2a JB |
394 | /** |
395 | * It will create a new entry. | |
396 | * Browse to it. | |
397 | * Then remove it. | |
398 | * | |
399 | * And it'll check that user won't be redirected to the view page of the content when it had been removed | |
400 | */ | |
401 | public function testViewAndDelete() | |
402 | { | |
403 | $this->logInAs('admin'); | |
404 | $client = $this->getClient(); | |
405 | ||
406 | // add a new content to be removed later | |
407 | $user = $client->getContainer() | |
408 | ->get('doctrine.orm.entity_manager') | |
409 | ->getRepository('WallabagUserBundle:User') | |
410 | ->findOneByUserName('admin'); | |
411 | ||
412 | $content = new Entry($user); | |
413 | $content->setUrl('http://1.1.1.1/entry'); | |
414 | $content->setReadingTime(12); | |
415 | $content->setDomainName('domain.io'); | |
416 | $content->setMimetype('text/html'); | |
417 | $content->setTitle('test title entry'); | |
418 | $content->setContent('This is my content /o/'); | |
419 | $content->setArchived(true); | |
420 | $content->setLanguage('fr'); | |
421 | ||
422 | $client->getContainer() | |
423 | ->get('doctrine.orm.entity_manager') | |
424 | ->persist($content); | |
425 | $client->getContainer() | |
426 | ->get('doctrine.orm.entity_manager') | |
427 | ->flush(); | |
428 | ||
429 | $client->request('GET', '/view/'.$content->getId()); | |
430 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
431 | ||
432 | $client->request('GET', '/delete/'.$content->getId()); | |
433 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | |
434 | ||
435 | $client->followRedirect(); | |
436 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
437 | } | |
438 | ||
3d2b2d62 J |
439 | public function testViewOtherUserEntry() |
440 | { | |
159986c4 | 441 | $this->logInAs('admin'); |
3d2b2d62 J |
442 | $client = $this->getClient(); |
443 | ||
444 | $content = $client->getContainer() | |
445 | ->get('doctrine.orm.entity_manager') | |
446 | ->getRepository('WallabagCoreBundle:Entry') | |
159986c4 | 447 | ->findOneByUsernameAndNotArchived('bob'); |
3d2b2d62 | 448 | |
159986c4 | 449 | $client->request('GET', '/view/'.$content->getId()); |
3d2b2d62 J |
450 | |
451 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | |
452 | } | |
26864574 | 453 | |
3f357ee2 | 454 | public function testFilterOnReadingTime() |
26864574 NL |
455 | { |
456 | $this->logInAs('admin'); | |
457 | $client = $this->getClient(); | |
458 | ||
459 | $crawler = $client->request('GET', '/unread/list'); | |
460 | ||
461 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
462 | ||
463 | $data = array( | |
464 | 'entry_filter[readingTime][right_number]' => 11, | |
8ce32af6 | 465 | 'entry_filter[readingTime][left_number]' => 11, |
26864574 NL |
466 | ); |
467 | ||
468 | $crawler = $client->submit($form, $data); | |
469 | ||
470 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | |
471 | } | |
ab2c93c7 | 472 | |
3f357ee2 NL |
473 | public function testFilterOnCreationDate() |
474 | { | |
475 | $this->logInAs('admin'); | |
476 | $client = $this->getClient(); | |
477 | ||
478 | $crawler = $client->request('GET', '/unread/list'); | |
479 | ||
480 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
481 | ||
482 | $data = array( | |
483 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), | |
8ce32af6 | 484 | 'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')), |
3f357ee2 NL |
485 | ); |
486 | ||
487 | $crawler = $client->submit($form, $data); | |
488 | ||
e1779760 | 489 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
3f357ee2 | 490 | |
f90af145 JB |
491 | $data = array( |
492 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), | |
493 | 'entry_filter[createdAt][right_date]' => date('d/m/Y'), | |
494 | ); | |
495 | ||
496 | $crawler = $client->submit($form, $data); | |
497 | ||
498 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | |
499 | ||
3f357ee2 NL |
500 | $data = array( |
501 | 'entry_filter[createdAt][left_date]' => '01/01/1970', | |
8ce32af6 | 502 | 'entry_filter[createdAt][right_date]' => '01/01/1970', |
3f357ee2 NL |
503 | ); |
504 | ||
505 | $crawler = $client->submit($form, $data); | |
506 | ||
507 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | |
3f357ee2 NL |
508 | } |
509 | ||
ab2c93c7 NL |
510 | public function testPaginationWithFilter() |
511 | { | |
512 | $this->logInAs('admin'); | |
513 | $client = $this->getClient(); | |
ab2c93c7 NL |
514 | $crawler = $client->request('GET', '/config'); |
515 | ||
516 | $form = $crawler->filter('button[id=config_save]')->form(); | |
517 | ||
518 | $data = array( | |
519 | 'config[items_per_page]' => '1', | |
520 | ); | |
521 | ||
522 | $client->submit($form, $data); | |
523 | ||
76cd8dbb | 524 | $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; |
ab2c93c7 | 525 | |
5c072d2b | 526 | $client->request('GET', 'unread/list'.$parameters); |
ab2c93c7 NL |
527 | |
528 | $this->assertContains($parameters, $client->getResponse()->getContent()); | |
e1779760 NL |
529 | |
530 | // reset pagination | |
531 | $crawler = $client->request('GET', '/config'); | |
532 | $form = $crawler->filter('button[id=config_save]')->form(); | |
533 | $data = array( | |
534 | 'config[items_per_page]' => '12', | |
535 | ); | |
536 | $client->submit($form, $data); | |
ab2c93c7 | 537 | } |
443cecd2 NL |
538 | |
539 | public function testFilterOnDomainName() | |
540 | { | |
541 | $this->logInAs('admin'); | |
542 | $client = $this->getClient(); | |
543 | ||
544 | $crawler = $client->request('GET', '/unread/list'); | |
545 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
546 | $data = array( | |
02d17813 | 547 | 'entry_filter[domainName]' => 'domain', |
443cecd2 NL |
548 | ); |
549 | ||
550 | $crawler = $client->submit($form, $data); | |
02d17813 | 551 | $this->assertCount(5, $crawler->filter('div[class=entry]')); |
443cecd2 NL |
552 | |
553 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
554 | $data = array( | |
8ce32af6 | 555 | 'entry_filter[domainName]' => 'wallabag', |
443cecd2 NL |
556 | ); |
557 | ||
558 | $crawler = $client->submit($form, $data); | |
559 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | |
560 | } | |
e1779760 NL |
561 | |
562 | public function testFilterOnStatus() | |
563 | { | |
564 | $this->logInAs('admin'); | |
565 | $client = $this->getClient(); | |
566 | ||
567 | $crawler = $client->request('GET', '/unread/list'); | |
568 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
569 | $form['entry_filter[isArchived]']->tick(); | |
570 | $form['entry_filter[isStarred]']->untick(); | |
571 | ||
572 | $crawler = $client->submit($form); | |
159986c4 | 573 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
e1779760 NL |
574 | |
575 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
576 | $form['entry_filter[isArchived]']->untick(); | |
577 | $form['entry_filter[isStarred]']->tick(); | |
578 | ||
579 | $crawler = $client->submit($form); | |
02d17813 | 580 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
e1779760 | 581 | } |
497e0cad NL |
582 | |
583 | public function testPreviewPictureFilter() | |
584 | { | |
585 | $this->logInAs('admin'); | |
586 | $client = $this->getClient(); | |
587 | ||
588 | $crawler = $client->request('GET', '/unread/list'); | |
589 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
590 | $form['entry_filter[previewPicture]']->tick(); | |
591 | ||
592 | $crawler = $client->submit($form); | |
593 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | |
594 | } | |
d4ebe5c5 JB |
595 | |
596 | public function testFilterOnLanguage() | |
597 | { | |
598 | $this->logInAs('admin'); | |
599 | $client = $this->getClient(); | |
600 | ||
601 | $crawler = $client->request('GET', '/unread/list'); | |
602 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
603 | $data = array( | |
159986c4 | 604 | 'entry_filter[language]' => 'fr', |
d4ebe5c5 JB |
605 | ); |
606 | ||
607 | $crawler = $client->submit($form, $data); | |
02d17813 | 608 | $this->assertCount(2, $crawler->filter('div[class=entry]')); |
d4ebe5c5 JB |
609 | |
610 | $form = $crawler->filter('button[id=submit-filter]')->form(); | |
611 | $data = array( | |
612 | 'entry_filter[language]' => 'en', | |
613 | ); | |
614 | ||
615 | $crawler = $client->submit($form, $data); | |
616 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | |
617 | } | |
93fd4692 | 618 | } |