]> git.immae.eu Git - github/wallabag/wallabag.git/blob - tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
Merge pull request #3398 from wallabag/issue-1735
[github/wallabag/wallabag.git] / tests / Wallabag / CoreBundle / Controller / EntryControllerTest.php
1 <?php
2
3 namespace Tests\Wallabag\CoreBundle\Controller;
4
5 use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6 use Wallabag\CoreBundle\Entity\Config;
7 use Wallabag\CoreBundle\Entity\Entry;
8 use Wallabag\CoreBundle\Entity\SiteCredential;
9
10 class EntryControllerTest extends WallabagCoreTestCase
11 {
12 const An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'http://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html';
13 public $downloadImagesEnabled = false;
14 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';
15
16 /**
17 * @after
18 *
19 * Ensure download_images_enabled is disabled after each script
20 */
21 public function tearDownImagesEnabled()
22 {
23 if ($this->downloadImagesEnabled) {
24 $client = static::createClient();
25 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
26
27 $this->downloadImagesEnabled = false;
28 }
29 }
30
31 public function testLogin()
32 {
33 $client = $this->getClient();
34
35 $client->request('GET', '/new');
36
37 $this->assertSame(302, $client->getResponse()->getStatusCode());
38 $this->assertContains('login', $client->getResponse()->headers->get('location'));
39 }
40
41 public function testQuickstart()
42 {
43 $this->logInAs('empty');
44 $client = $this->getClient();
45
46 $client->request('GET', '/unread/list');
47 $this->assertSame(302, $client->getResponse()->getStatusCode());
48 $crawler = $client->followRedirect();
49
50 $this->assertSame(200, $client->getResponse()->getStatusCode());
51 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
52 $this->assertContains('quickstart.intro.title', $body[0]);
53
54 // Test if quickstart is disabled when user has 1 entry
55 $crawler = $client->request('GET', '/new');
56
57 $this->assertSame(200, $client->getResponse()->getStatusCode());
58
59 $form = $crawler->filter('form[name=entry]')->form();
60
61 $data = [
62 'entry[url]' => $this->url,
63 ];
64
65 $client->submit($form, $data);
66 $this->assertSame(302, $client->getResponse()->getStatusCode());
67 $client->followRedirect();
68
69 $crawler = $client->request('GET', '/unread/list');
70 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
71 $this->assertContains('entry.list.number_on_the_page', $body[0]);
72 }
73
74 public function testGetNew()
75 {
76 $this->logInAs('admin');
77 $this->useTheme('baggy');
78 $client = $this->getClient();
79
80 $crawler = $client->request('GET', '/new');
81
82 $this->assertSame(200, $client->getResponse()->getStatusCode());
83
84 $this->assertCount(1, $crawler->filter('input[type=url]'));
85 $this->assertCount(1, $crawler->filter('form[name=entry]'));
86 }
87
88 public function testPostNewViaBookmarklet()
89 {
90 $this->logInAs('admin');
91 $this->useTheme('baggy');
92 $client = $this->getClient();
93
94 $crawler = $client->request('GET', '/');
95
96 $this->assertCount(4, $crawler->filter('div[class=entry]'));
97
98 // Good URL
99 $client->request('GET', '/bookmarklet', ['url' => $this->url]);
100 $this->assertSame(302, $client->getResponse()->getStatusCode());
101 $client->followRedirect();
102 $crawler = $client->request('GET', '/');
103 $this->assertCount(5, $crawler->filter('div[class=entry]'));
104
105 $em = $client->getContainer()
106 ->get('doctrine.orm.entity_manager');
107 $entry = $em
108 ->getRepository('WallabagCoreBundle:Entry')
109 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
110 $em->remove($entry);
111 $em->flush();
112 }
113
114 public function testPostNewEmpty()
115 {
116 $this->logInAs('admin');
117 $client = $this->getClient();
118
119 $crawler = $client->request('GET', '/new');
120
121 $this->assertSame(200, $client->getResponse()->getStatusCode());
122
123 $form = $crawler->filter('form[name=entry]')->form();
124
125 $crawler = $client->submit($form);
126
127 $this->assertSame(200, $client->getResponse()->getStatusCode());
128 $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text']));
129 $this->assertSame('This value should not be blank.', $alert[0]);
130 }
131
132 /**
133 * This test will require an internet connection.
134 */
135 public function testPostNewOk()
136 {
137 $this->logInAs('admin');
138 $client = $this->getClient();
139
140 $client->getContainer()->get('craue_config')->set('store_article_headers', 1);
141
142 $crawler = $client->request('GET', '/new');
143
144 $this->assertSame(200, $client->getResponse()->getStatusCode());
145
146 $form = $crawler->filter('form[name=entry]')->form();
147
148 $data = [
149 'entry[url]' => $this->url,
150 ];
151
152 $client->submit($form, $data);
153
154 $this->assertSame(302, $client->getResponse()->getStatusCode());
155
156 $content = $client->getContainer()
157 ->get('doctrine.orm.entity_manager')
158 ->getRepository('WallabagCoreBundle:Entry')
159 ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
160
161 $author = $content->getPublishedBy();
162
163 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
164 $this->assertSame($this->url, $content->getUrl());
165 $this->assertContains('Google', $content->getTitle());
166 $this->assertSame('fr', $content->getLanguage());
167 $this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s'));
168 $this->assertSame('Morgane Tual', $author[0]);
169 $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
170 $client->getContainer()->get('craue_config')->set('store_article_headers', 0);
171 }
172
173 public function testPostWithMultipleAuthors()
174 {
175 $url = 'http://www.liberation.fr/planete/2017/04/05/donald-trump-et-xi-jinping-tentative-de-flirt-en-floride_1560768';
176 $this->logInAs('admin');
177 $client = $this->getClient();
178
179 $crawler = $client->request('GET', '/new');
180
181 $this->assertSame(200, $client->getResponse()->getStatusCode());
182
183 $form = $crawler->filter('form[name=entry]')->form();
184
185 $data = [
186 'entry[url]' => $url,
187 ];
188
189 $client->submit($form, $data);
190
191 $this->assertSame(302, $client->getResponse()->getStatusCode());
192
193 $content = $client->getContainer()
194 ->get('doctrine.orm.entity_manager')
195 ->getRepository('WallabagCoreBundle:Entry')
196 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
197
198 $authors = $content->getPublishedBy();
199 $this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
200 $this->assertSame('fr', $content->getLanguage());
201 $this->assertSame('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
202 $this->assertSame('Frédéric Autran, correspondant à New York', $authors[1]);
203 }
204
205 public function testPostNewOkUrlExist()
206 {
207 $this->logInAs('admin');
208
209 $entry = new Entry($this->getLoggedInUser());
210 $entry->setUrl($this->url);
211 $this->getEntityManager()->persist($entry);
212 $this->getEntityManager()->flush();
213
214 $client = $this->getClient();
215
216 $crawler = $client->request('GET', '/new');
217
218 $this->assertSame(200, $client->getResponse()->getStatusCode());
219
220 $form = $crawler->filter('form[name=entry]')->form();
221
222 $data = [
223 'entry[url]' => $this->url,
224 ];
225
226 $client->submit($form, $data);
227
228 $this->assertSame(302, $client->getResponse()->getStatusCode());
229 $this->assertContains('/view/', $client->getResponse()->getTargetUrl());
230 }
231
232 public function testPostNewOkUrlExistWithAccent()
233 {
234 $this->logInAs('admin');
235 $client = $this->getClient();
236
237 $url = 'http://www.aritylabs.com/post/106091708292/des-contr%C3%B4leurs-optionnels-gr%C3%A2ce-%C3%A0-constmissing';
238
239 $crawler = $client->request('GET', '/new');
240
241 $this->assertSame(200, $client->getResponse()->getStatusCode());
242
243 $form = $crawler->filter('form[name=entry]')->form();
244
245 $data = [
246 'entry[url]' => $url,
247 ];
248
249 $client->submit($form, $data);
250
251 $crawler = $client->request('GET', '/new');
252
253 $this->assertSame(200, $client->getResponse()->getStatusCode());
254
255 $form = $crawler->filter('form[name=entry]')->form();
256
257 $data = [
258 'entry[url]' => $url,
259 ];
260
261 $client->submit($form, $data);
262
263 $this->assertSame(302, $client->getResponse()->getStatusCode());
264 $this->assertContains('/view/', $client->getResponse()->getTargetUrl());
265 }
266
267 /**
268 * This test will require an internet connection.
269 */
270 public function testPostNewThatWillBeTagged()
271 {
272 $this->logInAs('admin');
273 $client = $this->getClient();
274
275 $crawler = $client->request('GET', '/new');
276
277 $this->assertSame(200, $client->getResponse()->getStatusCode());
278
279 $form = $crawler->filter('form[name=entry]')->form();
280
281 $data = [
282 'entry[url]' => $url = 'https://github.com/wallabag/wallabag',
283 ];
284
285 $client->submit($form, $data);
286
287 $this->assertSame(302, $client->getResponse()->getStatusCode());
288 $this->assertContains('/', $client->getResponse()->getTargetUrl());
289
290 $em = $client->getContainer()
291 ->get('doctrine.orm.entity_manager');
292 $entry = $em
293 ->getRepository('WallabagCoreBundle:Entry')
294 ->findOneByUrl($url);
295 $tags = $entry->getTags();
296
297 $this->assertCount(2, $tags);
298 $this->assertContains('wallabag', $tags);
299 $this->assertSame('en', $entry->getLanguage());
300
301 $em->remove($entry);
302 $em->flush();
303
304 // and now re-submit it to test the cascade persistence for tags after entry removal
305 // related https://github.com/wallabag/wallabag/issues/2121
306 $crawler = $client->request('GET', '/new');
307
308 $this->assertSame(200, $client->getResponse()->getStatusCode());
309
310 $form = $crawler->filter('form[name=entry]')->form();
311
312 $data = [
313 'entry[url]' => $url = 'https://github.com/wallabag/wallabag/tree/master',
314 ];
315
316 $client->submit($form, $data);
317
318 $this->assertSame(302, $client->getResponse()->getStatusCode());
319 $this->assertContains('/', $client->getResponse()->getTargetUrl());
320
321 $entry = $em
322 ->getRepository('WallabagCoreBundle:Entry')
323 ->findOneByUrl($url);
324
325 $tags = $entry->getTags();
326
327 $this->assertCount(2, $tags);
328 $this->assertContains('wallabag', $tags);
329
330 $em->remove($entry);
331 $em->flush();
332 }
333
334 public function testArchive()
335 {
336 $this->logInAs('admin');
337 $client = $this->getClient();
338
339 $client->request('GET', '/archive/list');
340
341 $this->assertSame(200, $client->getResponse()->getStatusCode());
342 }
343
344 public function testUntagged()
345 {
346 $this->logInAs('admin');
347 $client = $this->getClient();
348
349 $client->request('GET', '/untagged/list');
350
351 $this->assertSame(200, $client->getResponse()->getStatusCode());
352 }
353
354 public function testStarred()
355 {
356 $this->logInAs('admin');
357 $client = $this->getClient();
358
359 $client->request('GET', '/starred/list');
360
361 $this->assertSame(200, $client->getResponse()->getStatusCode());
362 }
363
364 public function testRangeException()
365 {
366 $this->logInAs('admin');
367 $client = $this->getClient();
368
369 $client->request('GET', '/all/list/900');
370
371 $this->assertSame(302, $client->getResponse()->getStatusCode());
372 $this->assertSame('/all/list', $client->getResponse()->getTargetUrl());
373 }
374
375 public function testView()
376 {
377 $this->logInAs('admin');
378 $client = $this->getClient();
379
380 $entry = new Entry($this->getLoggedInUser());
381 $entry->setUrl('http://example.com/foo');
382 $entry->setTitle('title foo');
383 $entry->setContent('foo bar baz');
384 $this->getEntityManager()->persist($entry);
385 $this->getEntityManager()->flush();
386
387 $crawler = $client->request('GET', '/view/' . $entry->getId());
388
389 $this->assertSame(200, $client->getResponse()->getStatusCode());
390 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
391 $this->assertContains($entry->getTitle(), $body[0]);
392 }
393
394 /**
395 * This test will require an internet connection.
396 */
397 public function testReload()
398 {
399 $this->logInAs('admin');
400 $client = $this->getClient();
401
402 $entry = new Entry($this->getLoggedInUser());
403 $entry->setUrl($this->url);
404 $entry->setTitle('title foo');
405 $entry->setContent('');
406 $this->getEntityManager()->persist($entry);
407 $this->getEntityManager()->flush();
408 $this->getEntityManager()->clear();
409
410 $client->request('GET', '/reload/' . $entry->getId());
411
412 $this->assertSame(302, $client->getResponse()->getStatusCode());
413
414 $entry = $this->getEntityManager()
415 ->getRepository('WallabagCoreBundle:Entry')
416 ->find($entry->getId());
417
418 $this->assertNotEmpty($entry->getContent());
419 }
420
421 public function testReloadWithFetchingFailed()
422 {
423 $this->logInAs('admin');
424 $client = $this->getClient();
425
426 $entry = new Entry($this->getLoggedInUser());
427 $entry->setUrl('http://0.0.0.0/failed.html');
428 $this->getEntityManager()->persist($entry);
429 $this->getEntityManager()->flush();
430
431 $client->request('GET', '/reload/' . $entry->getId());
432
433 $this->assertSame(302, $client->getResponse()->getStatusCode());
434
435 // force EntityManager to clear previous entity
436 // otherwise, retrieve the same entity will retrieve change from the previous request :0
437 $this->getEntityManager()->clear();
438 $newContent = $this->getEntityManager()
439 ->getRepository('WallabagCoreBundle:Entry')
440 ->find($entry->getId());
441
442 $this->assertNotSame($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
443 }
444
445 public function testEdit()
446 {
447 $this->logInAs('admin');
448 $client = $this->getClient();
449
450 $entry = new Entry($this->getLoggedInUser());
451 $entry->setUrl($this->url);
452 $this->getEntityManager()->persist($entry);
453 $this->getEntityManager()->flush();
454
455 $crawler = $client->request('GET', '/edit/' . $entry->getId());
456
457 $this->assertSame(200, $client->getResponse()->getStatusCode());
458
459 $this->assertCount(1, $crawler->filter('input[id=entry_title]'));
460 $this->assertCount(1, $crawler->filter('button[id=entry_save]'));
461 }
462
463 public function testEditUpdate()
464 {
465 $this->logInAs('admin');
466 $client = $this->getClient();
467
468 $entry = new Entry($this->getLoggedInUser());
469 $entry->setUrl($this->url);
470 $this->getEntityManager()->persist($entry);
471 $this->getEntityManager()->flush();
472
473 $crawler = $client->request('GET', '/edit/' . $entry->getId());
474
475 $this->assertSame(200, $client->getResponse()->getStatusCode());
476
477 $form = $crawler->filter('button[type=submit]')->form();
478
479 $data = [
480 'entry[title]' => 'My updated title hehe :)',
481 'entry[origin_url]' => 'https://example.io',
482 ];
483
484 $client->submit($form, $data);
485
486 $this->assertSame(302, $client->getResponse()->getStatusCode());
487
488 $crawler = $client->followRedirect();
489
490 $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
491 $this->assertContains('My updated title hehe :)', $title[0]);
492 $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']));
493 $this->assertContains('example.io', trim($stats[1]));
494 }
495
496 public function testEditRemoveOriginUrl()
497 {
498 $this->logInAs('admin');
499 $client = $this->getClient();
500
501 $entry = new Entry($this->getLoggedInUser());
502 $entry->setUrl($this->url);
503 $this->getEntityManager()->persist($entry);
504 $this->getEntityManager()->flush();
505
506 $crawler = $client->request('GET', '/edit/' . $entry->getId());
507
508 $this->assertSame(200, $client->getResponse()->getStatusCode());
509
510 $form = $crawler->filter('button[type=submit]')->form();
511
512 $data = [
513 'entry[title]' => 'My updated title hehe :)',
514 'entry[origin_url]' => '',
515 ];
516
517 $client->submit($form, $data);
518
519 $this->assertSame(302, $client->getResponse()->getStatusCode());
520
521 $crawler = $client->followRedirect();
522
523 $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
524 $this->assertContains('My updated title hehe :)', $title[0]);
525 $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])));
526 $this->assertNotContains('example.io', trim($stats[0]));
527 }
528
529 public function testToggleArchive()
530 {
531 $this->logInAs('admin');
532 $client = $this->getClient();
533
534 $entry = new Entry($this->getLoggedInUser());
535 $entry->setUrl($this->url);
536 $this->getEntityManager()->persist($entry);
537 $this->getEntityManager()->flush();
538 $this->getEntityManager()->clear();
539
540 $client->request('GET', '/archive/' . $entry->getId());
541
542 $this->assertSame(302, $client->getResponse()->getStatusCode());
543
544 $res = $client->getContainer()
545 ->get('doctrine.orm.entity_manager')
546 ->getRepository('WallabagCoreBundle:Entry')
547 ->find($entry->getId());
548
549 $this->assertSame(1, $res->isArchived());
550 }
551
552 public function testToggleStar()
553 {
554 $this->logInAs('admin');
555 $client = $this->getClient();
556
557 $entry = new Entry($this->getLoggedInUser());
558 $entry->setUrl($this->url);
559 $this->getEntityManager()->persist($entry);
560 $this->getEntityManager()->flush();
561 $this->getEntityManager()->clear();
562
563 $client->request('GET', '/star/' . $entry->getId());
564
565 $this->assertSame(302, $client->getResponse()->getStatusCode());
566
567 $res = $client->getContainer()
568 ->get('doctrine.orm.entity_manager')
569 ->getRepository('WallabagCoreBundle:Entry')
570 ->findOneById($entry->getId());
571
572 $this->assertSame(1, $res->isStarred());
573 }
574
575 public function testDelete()
576 {
577 $this->logInAs('admin');
578 $client = $this->getClient();
579
580 $entry = new Entry($this->getLoggedInUser());
581 $entry->setUrl($this->url);
582 $this->getEntityManager()->persist($entry);
583 $this->getEntityManager()->flush();
584
585 $client->request('GET', '/delete/' . $entry->getId());
586
587 $this->assertSame(302, $client->getResponse()->getStatusCode());
588
589 $client->request('GET', '/delete/' . $entry->getId());
590
591 $this->assertSame(404, $client->getResponse()->getStatusCode());
592 }
593
594 /**
595 * It will create a new entry.
596 * Browse to it.
597 * Then remove it.
598 *
599 * And it'll check that user won't be redirected to the view page of the content when it had been removed
600 */
601 public function testViewAndDelete()
602 {
603 $this->logInAs('admin');
604 $client = $this->getClient();
605
606 $em = $client->getContainer()
607 ->get('doctrine.orm.entity_manager');
608
609 // add a new content to be removed later
610 $user = $em
611 ->getRepository('WallabagUserBundle:User')
612 ->findOneByUserName('admin');
613
614 $content = new Entry($user);
615 $content->setUrl('http://1.1.1.1/entry');
616 $content->setReadingTime(12);
617 $content->setDomainName('domain.io');
618 $content->setMimetype('text/html');
619 $content->setTitle('test title entry');
620 $content->setContent('This is my content /o/');
621 $content->setArchived(true);
622 $content->setLanguage('fr');
623
624 $em->persist($content);
625 $em->flush();
626
627 $client->request('GET', '/view/' . $content->getId());
628 $this->assertSame(200, $client->getResponse()->getStatusCode());
629
630 $client->request('GET', '/delete/' . $content->getId());
631 $this->assertSame(302, $client->getResponse()->getStatusCode());
632
633 $client->followRedirect();
634 $this->assertSame(200, $client->getResponse()->getStatusCode());
635 }
636
637 public function testViewOtherUserEntry()
638 {
639 $this->logInAs('admin');
640 $client = $this->getClient();
641
642 $content = $client->getContainer()
643 ->get('doctrine.orm.entity_manager')
644 ->getRepository('WallabagCoreBundle:Entry')
645 ->findOneByUsernameAndNotArchived('bob');
646
647 $client->request('GET', '/view/' . $content->getId());
648
649 $this->assertSame(403, $client->getResponse()->getStatusCode());
650 }
651
652 public function testFilterOnReadingTime()
653 {
654 $this->logInAs('admin');
655 $this->useTheme('baggy');
656 $client = $this->getClient();
657 $entry = new Entry($this->getLoggedInUser());
658 $entry->setUrl($this->url);
659 $entry->setReadingTime(22);
660 $this->getEntityManager()->persist($entry);
661 $this->getEntityManager()->flush();
662
663 $crawler = $client->request('GET', '/unread/list');
664
665 $form = $crawler->filter('button[id=submit-filter]')->form();
666
667 $data = [
668 'entry_filter[readingTime][right_number]' => 22,
669 'entry_filter[readingTime][left_number]' => 22,
670 ];
671
672 $crawler = $client->submit($form, $data);
673
674 $this->assertCount(1, $crawler->filter('div[class=entry]'));
675 }
676
677 public function testFilterOnReadingTimeWithNegativeValue()
678 {
679 $this->logInAs('admin');
680 $client = $this->getClient();
681
682 $crawler = $client->request('GET', '/unread/list');
683
684 $form = $crawler->filter('button[id=submit-filter]')->form();
685
686 $data = [
687 'entry_filter[readingTime][right_number]' => -22,
688 'entry_filter[readingTime][left_number]' => -22,
689 ];
690
691 $crawler = $client->submit($form, $data);
692
693 // forcing negative value results in no entry displayed
694 $this->assertCount(0, $crawler->filter('div[class=entry]'));
695 }
696
697 public function testFilterOnReadingTimeOnlyUpper()
698 {
699 $this->logInAs('admin');
700 $this->useTheme('baggy');
701 $client = $this->getClient();
702
703 $crawler = $client->request('GET', '/all/list');
704 $this->assertCount(5, $crawler->filter('div[class=entry]'));
705
706 $entry = new Entry($this->getLoggedInUser());
707 $entry->setUrl($this->url);
708 $entry->setReadingTime(23);
709 $this->getEntityManager()->persist($entry);
710 $this->getEntityManager()->flush();
711
712 $crawler = $client->request('GET', '/all/list');
713 $this->assertCount(6, $crawler->filter('div[class=entry]'));
714
715 $form = $crawler->filter('button[id=submit-filter]')->form();
716
717 $data = [
718 'entry_filter[readingTime][right_number]' => 22,
719 ];
720
721 $crawler = $client->submit($form, $data);
722
723 $this->assertCount(5, $crawler->filter('div[class=entry]'));
724 }
725
726 public function testFilterOnReadingTimeOnlyLower()
727 {
728 $this->logInAs('admin');
729 $this->useTheme('baggy');
730 $client = $this->getClient();
731
732 $crawler = $client->request('GET', '/unread/list');
733
734 $form = $crawler->filter('button[id=submit-filter]')->form();
735
736 $data = [
737 'entry_filter[readingTime][left_number]' => 22,
738 ];
739
740 $crawler = $client->submit($form, $data);
741
742 $this->assertCount(0, $crawler->filter('div[class=entry]'));
743
744 $entry = new Entry($this->getLoggedInUser());
745 $entry->setUrl($this->url);
746 $entry->setReadingTime(23);
747 $this->getEntityManager()->persist($entry);
748 $this->getEntityManager()->flush();
749
750 $crawler = $client->submit($form, $data);
751 $this->assertCount(1, $crawler->filter('div[class=entry]'));
752 }
753
754 public function testFilterOnUnreadStatus()
755 {
756 $this->logInAs('admin');
757 $this->useTheme('baggy');
758 $client = $this->getClient();
759
760 $crawler = $client->request('GET', '/all/list');
761
762 $form = $crawler->filter('button[id=submit-filter]')->form();
763
764 $data = [
765 'entry_filter[isUnread]' => true,
766 ];
767
768 $crawler = $client->submit($form, $data);
769
770 $this->assertCount(4, $crawler->filter('div[class=entry]'));
771
772 $entry = new Entry($this->getLoggedInUser());
773 $entry->setUrl($this->url);
774 $entry->setArchived(false);
775 $this->getEntityManager()->persist($entry);
776 $this->getEntityManager()->flush();
777
778 $crawler = $client->submit($form, $data);
779
780 $this->assertCount(5, $crawler->filter('div[class=entry]'));
781 }
782
783 public function testFilterOnCreationDate()
784 {
785 $this->logInAs('admin');
786 $this->useTheme('baggy');
787 $client = $this->getClient();
788
789 $crawler = $client->request('GET', '/unread/list');
790
791 $form = $crawler->filter('button[id=submit-filter]')->form();
792
793 $data = [
794 'entry_filter[createdAt][left_date]' => date('d/m/Y'),
795 'entry_filter[createdAt][right_date]' => date('d/m/Y', strtotime('+1 day')),
796 ];
797
798 $crawler = $client->submit($form, $data);
799
800 $this->assertCount(5, $crawler->filter('div[class=entry]'));
801
802 $data = [
803 'entry_filter[createdAt][left_date]' => date('d/m/Y'),
804 'entry_filter[createdAt][right_date]' => date('d/m/Y'),
805 ];
806
807 $crawler = $client->submit($form, $data);
808
809 $this->assertCount(5, $crawler->filter('div[class=entry]'));
810
811 $data = [
812 'entry_filter[createdAt][left_date]' => '01/01/1970',
813 'entry_filter[createdAt][right_date]' => '01/01/1970',
814 ];
815
816 $crawler = $client->submit($form, $data);
817
818 $this->assertCount(0, $crawler->filter('div[class=entry]'));
819 }
820
821 public function testPaginationWithFilter()
822 {
823 $this->logInAs('admin');
824 $client = $this->getClient();
825 $crawler = $client->request('GET', '/config');
826
827 $form = $crawler->filter('button[id=config_save]')->form();
828
829 $data = [
830 'config[items_per_page]' => '1',
831 ];
832
833 $client->submit($form, $data);
834
835 $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D=';
836
837 $client->request('GET', 'unread/list' . $parameters);
838
839 $this->assertContains($parameters, $client->getResponse()->getContent());
840
841 // reset pagination
842 $crawler = $client->request('GET', '/config');
843 $form = $crawler->filter('button[id=config_save]')->form();
844 $data = [
845 'config[items_per_page]' => '12',
846 ];
847 $client->submit($form, $data);
848 }
849
850 public function testFilterOnDomainName()
851 {
852 $this->logInAs('admin');
853 $this->useTheme('baggy');
854 $client = $this->getClient();
855
856 $crawler = $client->request('GET', '/unread/list');
857 $form = $crawler->filter('button[id=submit-filter]')->form();
858 $data = [
859 'entry_filter[domainName]' => 'domain',
860 ];
861
862 $crawler = $client->submit($form, $data);
863 $this->assertCount(5, $crawler->filter('div[class=entry]'));
864
865 $crawler = $client->request('GET', '/unread/list');
866 $form = $crawler->filter('button[id=submit-filter]')->form();
867 $data = [
868 'entry_filter[domainName]' => 'dOmain',
869 ];
870
871 $crawler = $client->submit($form, $data);
872 $this->assertCount(5, $crawler->filter('div[class=entry]'));
873
874 $form = $crawler->filter('button[id=submit-filter]')->form();
875 $data = [
876 'entry_filter[domainName]' => 'wallabag',
877 ];
878
879 $crawler = $client->submit($form, $data);
880 $this->assertCount(0, $crawler->filter('div[class=entry]'));
881 }
882
883 public function testFilterOnStatus()
884 {
885 $this->logInAs('admin');
886 $this->useTheme('baggy');
887 $client = $this->getClient();
888
889 $crawler = $client->request('GET', '/unread/list');
890 $form = $crawler->filter('button[id=submit-filter]')->form();
891 $form['entry_filter[isArchived]']->tick();
892 $form['entry_filter[isStarred]']->untick();
893
894 $crawler = $client->submit($form);
895 $this->assertCount(1, $crawler->filter('div[class=entry]'));
896
897 $form = $crawler->filter('button[id=submit-filter]')->form();
898 $form['entry_filter[isArchived]']->untick();
899 $form['entry_filter[isStarred]']->tick();
900
901 $crawler = $client->submit($form);
902 $this->assertCount(1, $crawler->filter('div[class=entry]'));
903 }
904
905 public function testFilterOnIsPublic()
906 {
907 $this->logInAs('admin');
908 $this->useTheme('baggy');
909 $client = $this->getClient();
910
911 $crawler = $client->request('GET', '/unread/list');
912 $form = $crawler->filter('button[id=submit-filter]')->form();
913 $form['entry_filter[isPublic]']->tick();
914
915 $crawler = $client->submit($form);
916 $this->assertCount(0, $crawler->filter('div[class=entry]'));
917 }
918
919 public function testPreviewPictureFilter()
920 {
921 $this->logInAs('admin');
922 $this->useTheme('baggy');
923 $client = $this->getClient();
924
925 $crawler = $client->request('GET', '/unread/list');
926 $form = $crawler->filter('button[id=submit-filter]')->form();
927 $form['entry_filter[previewPicture]']->tick();
928
929 $crawler = $client->submit($form);
930 $this->assertCount(1, $crawler->filter('div[class=entry]'));
931 }
932
933 public function testFilterOnLanguage()
934 {
935 $this->logInAs('admin');
936 $this->useTheme('baggy');
937 $client = $this->getClient();
938
939 $entry = new Entry($this->getLoggedInUser());
940 $entry->setUrl($this->url);
941 $entry->setLanguage('fr');
942 $this->getEntityManager()->persist($entry);
943 $this->getEntityManager()->flush();
944
945 $crawler = $client->request('GET', '/unread/list');
946 $form = $crawler->filter('button[id=submit-filter]')->form();
947 $data = [
948 'entry_filter[language]' => 'fr',
949 ];
950
951 $crawler = $client->submit($form, $data);
952 $this->assertCount(3, $crawler->filter('div[class=entry]'));
953
954 $form = $crawler->filter('button[id=submit-filter]')->form();
955 $data = [
956 'entry_filter[language]' => 'en',
957 ];
958
959 $crawler = $client->submit($form, $data);
960 $this->assertCount(2, $crawler->filter('div[class=entry]'));
961 }
962
963 public function testShareEntryPublicly()
964 {
965 $this->logInAs('admin');
966 $client = $this->getClient();
967
968 // sharing is enabled
969 $client->getContainer()->get('craue_config')->set('share_public', 1);
970
971 $content = new Entry($this->getLoggedInUser());
972 $content->setUrl($this->url);
973 $this->getEntityManager()->persist($content);
974 $this->getEntityManager()->flush();
975 $this->getEntityManager()->clear();
976
977 // no uid
978 $client->request('GET', '/share/' . $content->getUid());
979 $this->assertSame(404, $client->getResponse()->getStatusCode());
980
981 // generating the uid
982 $client->request('GET', '/share/' . $content->getId());
983 $this->assertSame(302, $client->getResponse()->getStatusCode());
984
985 // follow link with uid
986 $crawler = $client->followRedirect();
987 $this->assertSame(200, $client->getResponse()->getStatusCode());
988 $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
989 $this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
990 $this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control'));
991 $this->assertNotContains('no-cache', $client->getResponse()->headers->get('cache-control'));
992 $this->assertContains('og:title', $client->getResponse()->getContent());
993 $this->assertContains('og:type', $client->getResponse()->getContent());
994 $this->assertContains('og:url', $client->getResponse()->getContent());
995 $this->assertContains('og:image', $client->getResponse()->getContent());
996
997 // sharing is now disabled
998 $client->getContainer()->get('craue_config')->set('share_public', 0);
999 $client->request('GET', '/share/' . $content->getUid());
1000 $this->assertSame(404, $client->getResponse()->getStatusCode());
1001
1002 $client->request('GET', '/view/' . $content->getId());
1003 $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
1004
1005 // removing the share
1006 $client->request('GET', '/share/delete/' . $content->getId());
1007 $this->assertSame(302, $client->getResponse()->getStatusCode());
1008
1009 // share is now disable
1010 $client->request('GET', '/share/' . $content->getUid());
1011 $this->assertSame(404, $client->getResponse()->getStatusCode());
1012 }
1013
1014 public function testNewEntryWithDownloadImagesEnabled()
1015 {
1016 $this->downloadImagesEnabled = true;
1017 $this->logInAs('admin');
1018 $client = $this->getClient();
1019
1020 $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
1021 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
1022
1023 $crawler = $client->request('GET', '/new');
1024
1025 $this->assertSame(200, $client->getResponse()->getStatusCode());
1026
1027 $form = $crawler->filter('form[name=entry]')->form();
1028
1029 $data = [
1030 'entry[url]' => $url,
1031 ];
1032
1033 $client->submit($form, $data);
1034
1035 $this->assertSame(302, $client->getResponse()->getStatusCode());
1036
1037 $em = $client->getContainer()
1038 ->get('doctrine.orm.entity_manager');
1039
1040 $entry = $em
1041 ->getRepository('WallabagCoreBundle:Entry')
1042 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1043
1044 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
1045 $this->assertSame($url, $entry->getUrl());
1046 $this->assertContains('Judo', $entry->getTitle());
1047 // instead of checking for the filename (which might change) check that the image is now local
1048 $this->assertContains(rtrim($client->getContainer()->getParameter('domain_name'), '/') . '/assets/images/', $entry->getContent());
1049
1050 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
1051 }
1052
1053 /**
1054 * @depends testNewEntryWithDownloadImagesEnabled
1055 */
1056 public function testRemoveEntryWithDownloadImagesEnabled()
1057 {
1058 $this->downloadImagesEnabled = true;
1059 $this->logInAs('admin');
1060 $client = $this->getClient();
1061
1062 $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
1063 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
1064
1065 $crawler = $client->request('GET', '/new');
1066
1067 $this->assertSame(200, $client->getResponse()->getStatusCode());
1068
1069 $form = $crawler->filter('form[name=entry]')->form();
1070
1071 $data = [
1072 'entry[url]' => $url,
1073 ];
1074
1075 $client->submit($form, $data);
1076
1077 $this->assertSame(302, $client->getResponse()->getStatusCode());
1078
1079 $content = $client->getContainer()
1080 ->get('doctrine.orm.entity_manager')
1081 ->getRepository('WallabagCoreBundle:Entry')
1082 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1083
1084 $client->request('GET', '/delete/' . $content->getId());
1085
1086 $this->assertSame(302, $client->getResponse()->getStatusCode());
1087
1088 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
1089 }
1090
1091 public function testRedirectToHomepage()
1092 {
1093 $this->logInAs('empty');
1094 $client = $this->getClient();
1095
1096 // Redirect to homepage
1097 $config = $this->getLoggedInUser()->getConfig();
1098 $config->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
1099 $this->getEntityManager()->persist($config);
1100
1101 $entry = new Entry($this->getLoggedInUser());
1102 $entry->setUrl($this->url);
1103 $this->getEntityManager()->persist($entry);
1104
1105 $this->getEntityManager()->flush();
1106
1107 $client->request('GET', '/view/' . $entry->getId());
1108 $client->request('GET', '/archive/' . $entry->getId());
1109
1110 $this->assertSame(302, $client->getResponse()->getStatusCode());
1111 $this->assertSame('/', $client->getResponse()->headers->get('location'));
1112 }
1113
1114 public function testRedirectToCurrentPage()
1115 {
1116 $this->logInAs('empty');
1117 $client = $this->getClient();
1118
1119 // Redirect to current page
1120 $config = $this->getLoggedInUser()->getConfig();
1121 $config->setActionMarkAsRead(Config::REDIRECT_TO_CURRENT_PAGE);
1122 $this->getEntityManager()->persist($config);
1123
1124 $entry = new Entry($this->getLoggedInUser());
1125 $entry->setUrl($this->url);
1126 $this->getEntityManager()->persist($entry);
1127
1128 $this->getEntityManager()->flush();
1129
1130 $client->request('GET', '/view/' . $entry->getId());
1131 $client->request('GET', '/archive/' . $entry->getId());
1132
1133 $this->assertSame(302, $client->getResponse()->getStatusCode());
1134 $this->assertContains('/view/' . $entry->getId(), $client->getResponse()->headers->get('location'));
1135 }
1136
1137 public function testFilterOnHttpStatus()
1138 {
1139 $this->logInAs('admin');
1140 $this->useTheme('baggy');
1141 $client = $this->getClient();
1142
1143 $entry = new Entry($this->getLoggedInUser());
1144 $entry->setUrl('http://www.lemonde.fr/incorrect-url/');
1145 $entry->setHttpStatus(404);
1146 $this->getEntityManager()->persist($entry);
1147
1148 $this->getEntityManager()->flush();
1149
1150 $crawler = $client->request('GET', '/all/list');
1151 $form = $crawler->filter('button[id=submit-filter]')->form();
1152
1153 $data = [
1154 'entry_filter[httpStatus]' => 404,
1155 ];
1156
1157 $crawler = $client->submit($form, $data);
1158
1159 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1160
1161 $entry = new Entry($this->getLoggedInUser());
1162 $entry->setUrl($this->url);
1163 $entry->setHttpStatus(200);
1164 $this->getEntityManager()->persist($entry);
1165
1166 $entry = new Entry($this->getLoggedInUser());
1167 $entry->setUrl('http://www.nextinpact.com/news/101235-wallabag-alternative-libre-a-pocket-creuse-petit-a-petit-son-nid.htm');
1168 $entry->setHttpStatus(200);
1169 $this->getEntityManager()->persist($entry);
1170
1171 $this->getEntityManager()->flush();
1172
1173 $crawler = $client->request('GET', '/all/list');
1174 $form = $crawler->filter('button[id=submit-filter]')->form();
1175
1176 $data = [
1177 'entry_filter[httpStatus]' => 200,
1178 ];
1179
1180 $crawler = $client->submit($form, $data);
1181
1182 $this->assertCount(2, $crawler->filter('div[class=entry]'));
1183
1184 $crawler = $client->request('GET', '/all/list');
1185 $form = $crawler->filter('button[id=submit-filter]')->form();
1186
1187 $data = [
1188 'entry_filter[httpStatus]' => 1024,
1189 ];
1190
1191 $crawler = $client->submit($form, $data);
1192
1193 $this->assertCount(8, $crawler->filter('div[class=entry]'));
1194 }
1195
1196 public function testSearch()
1197 {
1198 $this->logInAs('admin');
1199 $this->useTheme('baggy');
1200 $client = $this->getClient();
1201
1202 $entry = new Entry($this->getLoggedInUser());
1203 $entry->setUrl($this->url);
1204 $entry->setTitle('test');
1205 $this->getEntityManager()->persist($entry);
1206 $this->getEntityManager()->flush();
1207
1208 // Search on unread list
1209 $crawler = $client->request('GET', '/unread/list');
1210
1211 $form = $crawler->filter('form[name=search]')->form();
1212 $data = [
1213 'search_entry[term]' => 'title',
1214 ];
1215
1216 $crawler = $client->submit($form, $data);
1217
1218 $this->assertCount(4, $crawler->filter('div[class=entry]'));
1219
1220 // Search on starred list
1221 $crawler = $client->request('GET', '/starred/list');
1222
1223 $entry = new Entry($this->getLoggedInUser());
1224 $entry->setUrl('http://localhost/foo/bar');
1225 $entry->setTitle('testeur');
1226 $entry->setStarred(true);
1227 $this->getEntityManager()->persist($entry);
1228 $this->getEntityManager()->flush();
1229
1230 $form = $crawler->filter('form[name=search]')->form();
1231 $data = [
1232 'search_entry[term]' => 'testeur',
1233 ];
1234
1235 $crawler = $client->submit($form, $data);
1236
1237 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1238
1239 $crawler = $client->request('GET', '/archive/list');
1240
1241 // Added new article to test on archive list
1242 $entry = new Entry($this->getLoggedInUser());
1243 $entry->setUrl('http://0.0.0.0/foo/baz/qux');
1244 $entry->setTitle('Le manège');
1245 $entry->setArchived(true);
1246 $this->getEntityManager()->persist($entry);
1247 $this->getEntityManager()->flush();
1248
1249 $form = $crawler->filter('form[name=search]')->form();
1250 $data = [
1251 'search_entry[term]' => 'manège',
1252 ];
1253
1254 $crawler = $client->submit($form, $data);
1255
1256 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1257 $client->request('GET', '/delete/' . $entry->getId());
1258
1259 // test on list of all articles
1260 $crawler = $client->request('GET', '/all/list');
1261
1262 $form = $crawler->filter('form[name=search]')->form();
1263 $data = [
1264 'search_entry[term]' => 'wxcvbnqsdf', // a string not available in the database
1265 ];
1266
1267 $crawler = $client->submit($form, $data);
1268
1269 $this->assertCount(0, $crawler->filter('div[class=entry]'));
1270
1271 // test url search on list of all articles
1272 $entry = new Entry($this->getLoggedInUser());
1273 $entry->setUrl('http://domain/qux');
1274 $entry->setTitle('Le manège');
1275 $entry->setArchived(true);
1276 $this->getEntityManager()->persist($entry);
1277 $this->getEntityManager()->flush();
1278
1279 $crawler = $client->request('GET', '/all/list');
1280
1281 $form = $crawler->filter('form[name=search]')->form();
1282 $data = [
1283 'search_entry[term]' => 'domain', // the search will match an entry with 'domain' in its url
1284 ];
1285
1286 $crawler = $client->submit($form, $data);
1287
1288 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1289
1290 // same as previous test but for case-sensitivity
1291 $crawler = $client->request('GET', '/all/list');
1292
1293 $form = $crawler->filter('form[name=search]')->form();
1294 $data = [
1295 'search_entry[term]' => 'doMain', // the search will match an entry with 'domain' in its url
1296 ];
1297
1298 $crawler = $client->submit($form, $data);
1299
1300 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1301 }
1302
1303 public function dataForLanguage()
1304 {
1305 return [
1306 'ru' => [
1307 'https://www.pravda.ru/world/09-06-2017/1337283-qatar-0/',
1308 'ru',
1309 ],
1310 'fr-FR' => [
1311 'https://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/',
1312 'fr_FR',
1313 ],
1314 'de' => [
1315 'http://www.bild.de/politik/ausland/theresa-may/wahlbeben-grossbritannien-analyse-52108924.bild.html',
1316 'de',
1317 ],
1318 'it' => [
1319 'http://www.ansa.it/sito/notizie/mondo/europa/2017/06/08/voto-gb-seggi-aperti-misure-sicurezza-rafforzate_0cb71f7f-e23b-4d5f-95ca-bc12296419f0.html',
1320 'it',
1321 ],
1322 'zh_CN' => [
1323 'http://www.hao123.com/shequ?__noscript__-=1',
1324 'zh_CN',
1325 ],
1326 'de_AT' => [
1327 'https://buy.garmin.com/de-AT/AT/catalog/product/compareResult.ep?compareProduct=112885&compareProduct=36728',
1328 'de_AT',
1329 ],
1330 'ru_RU' => [
1331 'http://netler.ru/ikt/windows-error-reporting.htm',
1332 'ru_RU',
1333 ],
1334 'pt_BR' => [
1335 'http://precodoscombustiveis.com.br/postos/cidade/4121/pr/maringa',
1336 'pt_BR',
1337 ],
1338 'fucked_list_of_languages' => [
1339 'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home',
1340 null,
1341 ],
1342 'es-ES' => [
1343 'https://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google/',
1344 'es_ES',
1345 ],
1346 ];
1347 }
1348
1349 /**
1350 * @dataProvider dataForLanguage
1351 */
1352 public function testLanguageValidation($url, $expectedLanguage)
1353 {
1354 $this->logInAs('admin');
1355 $client = $this->getClient();
1356
1357 $crawler = $client->request('GET', '/new');
1358
1359 $this->assertSame(200, $client->getResponse()->getStatusCode());
1360
1361 $form = $crawler->filter('form[name=entry]')->form();
1362
1363 $data = [
1364 'entry[url]' => $url,
1365 ];
1366
1367 $client->submit($form, $data);
1368
1369 $this->assertSame(302, $client->getResponse()->getStatusCode());
1370
1371 $content = $client->getContainer()
1372 ->get('doctrine.orm.entity_manager')
1373 ->getRepository('WallabagCoreBundle:Entry')
1374 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1375
1376 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
1377 $this->assertSame($url, $content->getUrl());
1378 $this->assertSame($expectedLanguage, $content->getLanguage());
1379 }
1380
1381 /**
1382 * This test will require an internet connection.
1383 */
1384 public function testRestrictedArticle()
1385 {
1386 $url = 'https://www.monde-diplomatique.fr/2017/05/BONNET/57475';
1387 $this->logInAs('admin');
1388 $client = $this->getClient();
1389 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
1390
1391 // enable restricted access
1392 $client->getContainer()->get('craue_config')->set('restricted_access', 1);
1393
1394 // create a new site_credential
1395 $user = $client->getContainer()->get('security.token_storage')->getToken()->getUser();
1396 $credential = new SiteCredential($user);
1397 $credential->setHost('monde-diplomatique.fr');
1398 $credential->setUsername($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('foo'));
1399 $credential->setPassword($client->getContainer()->get('wallabag_core.helper.crypto_proxy')->crypt('bar'));
1400
1401 $em->persist($credential);
1402 $em->flush();
1403
1404 $crawler = $client->request('GET', '/new');
1405
1406 $this->assertSame(200, $client->getResponse()->getStatusCode());
1407
1408 $form = $crawler->filter('form[name=entry]')->form();
1409
1410 $data = [
1411 'entry[url]' => $url,
1412 ];
1413
1414 $client->submit($form, $data);
1415
1416 $this->assertSame(302, $client->getResponse()->getStatusCode());
1417
1418 $crawler = $client->followRedirect();
1419
1420 $this->assertSame(200, $client->getResponse()->getStatusCode());
1421 $this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]);
1422
1423 $content = $em
1424 ->getRepository('WallabagCoreBundle:Entry')
1425 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1426
1427 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
1428 $this->assertSame('Crimes et réformes aux Philippines', $content->getTitle());
1429
1430 $client->getContainer()->get('craue_config')->set('restricted_access', 0);
1431 }
1432 }