aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/CoreBundle/Controller')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php54
1 files changed, 47 insertions, 7 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index ca275b32..4ac4548b 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -9,6 +9,7 @@ use Wallabag\CoreBundle\Entity\SiteCredential;
9 9
10class EntryControllerTest extends WallabagCoreTestCase 10class EntryControllerTest extends WallabagCoreTestCase
11{ 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';
12 public $downloadImagesEnabled = false; 13 public $downloadImagesEnabled = false;
13 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'; 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';
14 15
@@ -136,6 +137,8 @@ class EntryControllerTest extends WallabagCoreTestCase
136 $this->logInAs('admin'); 137 $this->logInAs('admin');
137 $client = $this->getClient(); 138 $client = $this->getClient();
138 139
140 $client->getContainer()->get('craue_config')->set('store_article_headers', 1);
141
139 $crawler = $client->request('GET', '/new'); 142 $crawler = $client->request('GET', '/new');
140 143
141 $this->assertSame(200, $client->getResponse()->getStatusCode()); 144 $this->assertSame(200, $client->getResponse()->getStatusCode());
@@ -161,9 +164,10 @@ class EntryControllerTest extends WallabagCoreTestCase
161 $this->assertSame($this->url, $content->getUrl()); 164 $this->assertSame($this->url, $content->getUrl());
162 $this->assertContains('Google', $content->getTitle()); 165 $this->assertContains('Google', $content->getTitle());
163 $this->assertSame('fr', $content->getLanguage()); 166 $this->assertSame('fr', $content->getLanguage());
164 $this->assertSame('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s')); 167 $this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s'));
165 $this->assertSame('Morgane Tual', $author[0]); 168 $this->assertSame('Morgane Tual', $author[0]);
166 $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); 169 $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
170 $client->getContainer()->get('craue_config')->set('store_article_headers', 0);
167 } 171 }
168 172
169 public function testPostWithMultipleAuthors() 173 public function testPostWithMultipleAuthors()
@@ -474,6 +478,40 @@ class EntryControllerTest extends WallabagCoreTestCase
474 478
475 $data = [ 479 $data = [
476 'entry[title]' => 'My updated title hehe :)', 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]' => '',
477 ]; 515 ];
478 516
479 $client->submit($form, $data); 517 $client->submit($form, $data);
@@ -482,8 +520,10 @@ class EntryControllerTest extends WallabagCoreTestCase
482 520
483 $crawler = $client->followRedirect(); 521 $crawler = $client->followRedirect();
484 522
485 $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); 523 $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text']));
486 $this->assertContains('My updated title hehe :)', $alert[0]); 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]));
487 } 527 }
488 528
489 public function testToggleArchive() 529 public function testToggleArchive()
@@ -977,7 +1017,7 @@ class EntryControllerTest extends WallabagCoreTestCase
977 $this->logInAs('admin'); 1017 $this->logInAs('admin');
978 $client = $this->getClient(); 1018 $client = $this->getClient();
979 1019
980 $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route'; 1020 $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
981 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1); 1021 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
982 1022
983 $crawler = $client->request('GET', '/new'); 1023 $crawler = $client->request('GET', '/new');
@@ -1003,9 +1043,9 @@ class EntryControllerTest extends WallabagCoreTestCase
1003 1043
1004 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); 1044 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
1005 $this->assertSame($url, $entry->getUrl()); 1045 $this->assertSame($url, $entry->getUrl());
1006 $this->assertContains('Perpignan', $entry->getTitle()); 1046 $this->assertContains('Judo', $entry->getTitle());
1007 // instead of checking for the filename (which might change) check that the image is now local 1047 // instead of checking for the filename (which might change) check that the image is now local
1008 $this->assertContains($client->getContainer()->getParameter('domain_name') . '/assets/images/', $entry->getContent()); 1048 $this->assertContains(rtrim($client->getContainer()->getParameter('domain_name'), '/') . '/assets/images/', $entry->getContent());
1009 1049
1010 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); 1050 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
1011 } 1051 }
@@ -1019,7 +1059,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1019 $this->logInAs('admin'); 1059 $this->logInAs('admin');
1020 $client = $this->getClient(); 1060 $client = $this->getClient();
1021 1061
1022 $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route'; 1062 $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE;
1023 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1); 1063 $client->getContainer()->get('craue_config')->set('download_images_enabled', 1);
1024 1064
1025 $crawler = $client->request('GET', '/new'); 1065 $crawler = $client->request('GET', '/new');