diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 619 |
1 files changed, 0 insertions, 619 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php deleted file mode 100644 index df4c34cd..00000000 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ /dev/null | |||
@@ -1,619 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | ||
6 | use Wallabag\CoreBundle\Entity\Entry; | ||
7 | |||
8 | class EntryControllerTest extends WallabagCoreTestCase | ||
9 | { | ||
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 | |||
12 | public function testLogin() | ||
13 | { | ||
14 | $client = $this->getClient(); | ||
15 | |||
16 | $client->request('GET', '/new'); | ||
17 | |||
18 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
19 | $this->assertContains('login', $client->getResponse()->headers->get('location')); | ||
20 | } | ||
21 | |||
22 | public function testQuickstart() | ||
23 | { | ||
24 | $this->logInAs('empty'); | ||
25 | $client = $this->getClient(); | ||
26 | |||
27 | $client->request('GET', '/unread/list'); | ||
28 | $crawler = $client->followRedirect(); | ||
29 | |||
30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
31 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
32 | $this->assertContains('quickstart.intro.paragraph_1', $body[0]); | ||
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 | |||
39 | $form = $crawler->filter('form[name=entry]')->form(); | ||
40 | |||
41 | $data = [ | ||
42 | 'entry[url]' => $this->url, | ||
43 | ]; | ||
44 | |||
45 | $client->submit($form, $data); | ||
46 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
47 | $client->followRedirect(); | ||
48 | |||
49 | $crawler = $client->request('GET', '/unread/list'); | ||
50 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
51 | $this->assertContains('entry.list.number_on_the_page', $body[0]); | ||
52 | } | ||
53 | |||
54 | public function testGetNew() | ||
55 | { | ||
56 | $this->logInAs('admin'); | ||
57 | $client = $this->getClient(); | ||
58 | |||
59 | $crawler = $client->request('GET', '/new'); | ||
60 | |||
61 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
62 | |||
63 | $this->assertCount(1, $crawler->filter('input[type=url]')); | ||
64 | $this->assertCount(1, $crawler->filter('form[name=entry]')); | ||
65 | } | ||
66 | |||
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 | ||
77 | $client->request('GET', '/bookmarklet', ['url' => $this->url]); | ||
78 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
79 | $client->followRedirect(); | ||
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') | ||
87 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
88 | $em->remove($entry); | ||
89 | $em->flush(); | ||
90 | } | ||
91 | |||
92 | public function testPostNewEmpty() | ||
93 | { | ||
94 | $this->logInAs('admin'); | ||
95 | $client = $this->getClient(); | ||
96 | |||
97 | $crawler = $client->request('GET', '/new'); | ||
98 | |||
99 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
100 | |||
101 | $form = $crawler->filter('form[name=entry]')->form(); | ||
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(['_text'])); | ||
107 | $this->assertEquals('This value should not be blank.', $alert[0]); | ||
108 | } | ||
109 | |||
110 | /** | ||
111 | * This test will require an internet connection. | ||
112 | */ | ||
113 | public function testPostNewOk() | ||
114 | { | ||
115 | $this->logInAs('admin'); | ||
116 | $client = $this->getClient(); | ||
117 | |||
118 | $crawler = $client->request('GET', '/new'); | ||
119 | |||
120 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
121 | |||
122 | $form = $crawler->filter('form[name=entry]')->form(); | ||
123 | |||
124 | $data = [ | ||
125 | 'entry[url]' => $this->url, | ||
126 | ]; | ||
127 | |||
128 | $client->submit($form, $data); | ||
129 | |||
130 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
131 | |||
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 | } | ||
141 | |||
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 | |||
151 | $form = $crawler->filter('form[name=entry]')->form(); | ||
152 | |||
153 | $data = [ | ||
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()); | ||
161 | } | ||
162 | |||
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 | |||
175 | $form = $crawler->filter('form[name=entry]')->form(); | ||
176 | |||
177 | $data = [ | ||
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 | |||
185 | $client->followRedirect(); | ||
186 | |||
187 | $em = $client->getContainer() | ||
188 | ->get('doctrine.orm.entity_manager'); | ||
189 | $entry = $em | ||
190 | ->getRepository('WallabagCoreBundle:Entry') | ||
191 | ->findOneByUrl($url); | ||
192 | $tags = $entry->getTags(); | ||
193 | |||
194 | $this->assertCount(1, $tags); | ||
195 | $this->assertEquals('wallabag', $tags[0]->getLabel()); | ||
196 | |||
197 | $em->remove($entry); | ||
198 | $em->flush(); | ||
199 | } | ||
200 | |||
201 | public function testArchive() | ||
202 | { | ||
203 | $this->logInAs('admin'); | ||
204 | $client = $this->getClient(); | ||
205 | |||
206 | $client->request('GET', '/archive/list'); | ||
207 | |||
208 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
209 | } | ||
210 | |||
211 | public function testStarred() | ||
212 | { | ||
213 | $this->logInAs('admin'); | ||
214 | $client = $this->getClient(); | ||
215 | |||
216 | $client->request('GET', '/starred/list'); | ||
217 | |||
218 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
219 | } | ||
220 | |||
221 | public function testRangeException() | ||
222 | { | ||
223 | $this->logInAs('admin'); | ||
224 | $client = $this->getClient(); | ||
225 | |||
226 | $client->request('GET', '/all/list/900'); | ||
227 | |||
228 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
229 | $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl()); | ||
230 | } | ||
231 | |||
232 | /** | ||
233 | * @depends testPostNewOk | ||
234 | */ | ||
235 | public function testView() | ||
236 | { | ||
237 | $this->logInAs('admin'); | ||
238 | $client = $this->getClient(); | ||
239 | |||
240 | $content = $client->getContainer() | ||
241 | ->get('doctrine.orm.entity_manager') | ||
242 | ->getRepository('WallabagCoreBundle:Entry') | ||
243 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
244 | |||
245 | $crawler = $client->request('GET', '/view/'.$content->getId()); | ||
246 | |||
247 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
248 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); | ||
249 | $this->assertContains($content->getTitle(), $body[0]); | ||
250 | } | ||
251 | |||
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') | ||
265 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
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') | ||
279 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
280 | |||
281 | $this->assertNotEmpty($content->getContent()); | ||
282 | } | ||
283 | |||
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') | ||
292 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
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') | ||
310 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
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 | |||
318 | $data = [ | ||
319 | 'entry[title]' => 'My updated title hehe :)', | ||
320 | ]; | ||
321 | |||
322 | $client->submit($form, $data); | ||
323 | |||
324 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
325 | |||
326 | $crawler = $client->followRedirect(); | ||
327 | |||
328 | $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); | ||
329 | $this->assertContains('My updated title hehe :)', $alert[0]); | ||
330 | } | ||
331 | |||
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') | ||
340 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
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') | ||
349 | ->find($content->getId()); | ||
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') | ||
362 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
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') | ||
384 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | ||
385 | |||
386 | $client->request('GET', '/delete/'.$content->getId()); | ||
387 | |||
388 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
389 | |||
390 | $client->request('GET', '/delete/'.$content->getId()); | ||
391 | |||
392 | $this->assertEquals(404, $client->getResponse()->getStatusCode()); | ||
393 | } | ||
394 | |||
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 | |||
440 | public function testViewOtherUserEntry() | ||
441 | { | ||
442 | $this->logInAs('admin'); | ||
443 | $client = $this->getClient(); | ||
444 | |||
445 | $content = $client->getContainer() | ||
446 | ->get('doctrine.orm.entity_manager') | ||
447 | ->getRepository('WallabagCoreBundle:Entry') | ||
448 | ->findOneByUsernameAndNotArchived('bob'); | ||
449 | |||
450 | $client->request('GET', '/view/'.$content->getId()); | ||
451 | |||
452 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | ||
453 | } | ||
454 | |||
455 | public function testFilterOnReadingTime() | ||
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 | |||
464 | $data = [ | ||
465 | 'entry_filter[readingTime][right_number]' => 22, | ||
466 | 'entry_filter[readingTime][left_number]' => 22, | ||
467 | ]; | ||
468 | |||
469 | $crawler = $client->submit($form, $data); | ||
470 | |||
471 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | ||
472 | } | ||
473 | |||
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 | |||
483 | $data = [ | ||
484 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), | ||
485 | 'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')), | ||
486 | ]; | ||
487 | |||
488 | $crawler = $client->submit($form, $data); | ||
489 | |||
490 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | ||
491 | |||
492 | $data = [ | ||
493 | 'entry_filter[createdAt][left_date]' => date('d/m/Y'), | ||
494 | 'entry_filter[createdAt][right_date]' => date('d/m/Y'), | ||
495 | ]; | ||
496 | |||
497 | $crawler = $client->submit($form, $data); | ||
498 | |||
499 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | ||
500 | |||
501 | $data = [ | ||
502 | 'entry_filter[createdAt][left_date]' => '01/01/1970', | ||
503 | 'entry_filter[createdAt][right_date]' => '01/01/1970', | ||
504 | ]; | ||
505 | |||
506 | $crawler = $client->submit($form, $data); | ||
507 | |||
508 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | ||
509 | } | ||
510 | |||
511 | public function testPaginationWithFilter() | ||
512 | { | ||
513 | $this->logInAs('admin'); | ||
514 | $client = $this->getClient(); | ||
515 | $crawler = $client->request('GET', '/config'); | ||
516 | |||
517 | $form = $crawler->filter('button[id=config_save]')->form(); | ||
518 | |||
519 | $data = [ | ||
520 | 'config[items_per_page]' => '1', | ||
521 | ]; | ||
522 | |||
523 | $client->submit($form, $data); | ||
524 | |||
525 | $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; | ||
526 | |||
527 | $client->request('GET', 'unread/list'.$parameters); | ||
528 | |||
529 | $this->assertContains($parameters, $client->getResponse()->getContent()); | ||
530 | |||
531 | // reset pagination | ||
532 | $crawler = $client->request('GET', '/config'); | ||
533 | $form = $crawler->filter('button[id=config_save]')->form(); | ||
534 | $data = [ | ||
535 | 'config[items_per_page]' => '12', | ||
536 | ]; | ||
537 | $client->submit($form, $data); | ||
538 | } | ||
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(); | ||
547 | $data = [ | ||
548 | 'entry_filter[domainName]' => 'domain', | ||
549 | ]; | ||
550 | |||
551 | $crawler = $client->submit($form, $data); | ||
552 | $this->assertCount(5, $crawler->filter('div[class=entry]')); | ||
553 | |||
554 | $form = $crawler->filter('button[id=submit-filter]')->form(); | ||
555 | $data = [ | ||
556 | 'entry_filter[domainName]' => 'wallabag', | ||
557 | ]; | ||
558 | |||
559 | $crawler = $client->submit($form, $data); | ||
560 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | ||
561 | } | ||
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); | ||
574 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | ||
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); | ||
581 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | ||
582 | } | ||
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 | } | ||
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(); | ||
604 | $data = [ | ||
605 | 'entry_filter[language]' => 'fr', | ||
606 | ]; | ||
607 | |||
608 | $crawler = $client->submit($form, $data); | ||
609 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | ||
610 | |||
611 | $form = $crawler->filter('button[id=submit-filter]')->form(); | ||
612 | $data = [ | ||
613 | 'entry_filter[language]' => 'en', | ||
614 | ]; | ||
615 | |||
616 | $crawler = $client->submit($form, $data); | ||
617 | $this->assertCount(2, $crawler->filter('div[class=entry]')); | ||
618 | } | ||
619 | } | ||