X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FEntryControllerTest.php;h=4ac4548b2624b2f75035e525a4f4e0fb5ec577f9;hb=95b7d92ea5f92078c2e1fed0b346a9722de762c4;hp=33bfa71e67d5c2e2f8a4abc03913a40e3b677fd6;hpb=ea127a401b79230eede13afd655d9fb7789c8059;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 33bfa71e..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; class EntryControllerTest extends WallabagCoreTestCase { + 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'; public $downloadImagesEnabled = false; 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'; @@ -136,6 +137,8 @@ class EntryControllerTest extends WallabagCoreTestCase $this->logInAs('admin'); $client = $this->getClient(); + $client->getContainer()->get('craue_config')->set('store_article_headers', 1); + $crawler = $client->request('GET', '/new'); $this->assertSame(200, $client->getResponse()->getStatusCode()); @@ -161,9 +164,10 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertSame($this->url, $content->getUrl()); $this->assertContains('Google', $content->getTitle()); $this->assertSame('fr', $content->getLanguage()); - $this->assertSame('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s')); + $this->assertSame('2015-03-28 11:43:19', $content->getPublishedAt()->format('Y-m-d H:i:s')); $this->assertSame('Morgane Tual', $author[0]); $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); + $client->getContainer()->get('craue_config')->set('store_article_headers', 0); } public function testPostWithMultipleAuthors() @@ -474,6 +478,40 @@ class EntryControllerTest extends WallabagCoreTestCase $data = [ 'entry[title]' => 'My updated title hehe :)', + 'entry[origin_url]' => 'https://example.io', + ]; + + $client->submit($form, $data); + + $this->assertSame(302, $client->getResponse()->getStatusCode()); + + $crawler = $client->followRedirect(); + + $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); + $this->assertContains('My updated title hehe :)', $title[0]); + $this->assertGreaterThan(1, $stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text'])); + $this->assertContains('example.io', trim($stats[1])); + } + + public function testEditRemoveOriginUrl() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $entry = new Entry($this->getLoggedInUser()); + $entry->setUrl($this->url); + $this->getEntityManager()->persist($entry); + $this->getEntityManager()->flush(); + + $crawler = $client->request('GET', '/edit/' . $entry->getId()); + + $this->assertSame(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('button[type=submit]')->form(); + + $data = [ + 'entry[title]' => 'My updated title hehe :)', + 'entry[origin_url]' => '', ]; $client->submit($form, $data); @@ -482,8 +520,10 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->followRedirect(); - $this->assertGreaterThan(1, $alert = $crawler->filter('div[id=article] h1')->extract(['_text'])); - $this->assertContains('My updated title hehe :)', $alert[0]); + $this->assertGreaterThan(1, $title = $crawler->filter('div[id=article] h1')->extract(['_text'])); + $this->assertContains('My updated title hehe :)', $title[0]); + $this->assertSame(1, count($stats = $crawler->filter('div[class=tools] ul[class=stats] li a[class=tool]')->extract(['_text']))); + $this->assertNotContains('example.io', trim($stats[0])); } public function testToggleArchive() @@ -977,7 +1017,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->logInAs('admin'); $client = $this->getClient(); - $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route'; + $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE; $client->getContainer()->get('craue_config')->set('download_images_enabled', 1); $crawler = $client->request('GET', '/new'); @@ -1003,9 +1043,9 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); $this->assertSame($url, $entry->getUrl()); - $this->assertContains('Perpignan', $entry->getTitle()); + $this->assertContains('Judo', $entry->getTitle()); // instead of checking for the filename (which might change) check that the image is now local - $this->assertContains($client->getContainer()->getParameter('domain_name') . '/assets/images/', $entry->getContent()); + $this->assertContains(rtrim($client->getContainer()->getParameter('domain_name'), '/') . '/assets/images/', $entry->getContent()); $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); } @@ -1019,7 +1059,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->logInAs('admin'); $client = $this->getClient(); - $url = 'http://www.20minutes.fr/montpellier/1952003-20161030-video-car-tombe-panne-rugbymen-perpignan-improvisent-melee-route'; + $url = self::An_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE; $client->getContainer()->get('craue_config')->set('download_images_enabled', 1); $crawler = $client->request('GET', '/new'); @@ -1268,7 +1308,7 @@ class EntryControllerTest extends WallabagCoreTestCase 'ru', ], 'fr-FR' => [ - 'http://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/', + 'https://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/', 'fr_FR', ], 'de' => [ @@ -1300,7 +1340,7 @@ class EntryControllerTest extends WallabagCoreTestCase null, ], 'es-ES' => [ - 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google/', + 'https://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google/', 'es_ES', ], ]; @@ -1343,7 +1383,7 @@ class EntryControllerTest extends WallabagCoreTestCase */ public function testRestrictedArticle() { - $url = 'http://www.monde-diplomatique.fr/2017/05/BONNET/57475'; + $url = 'https://www.monde-diplomatique.fr/2017/05/BONNET/57475'; $this->logInAs('admin'); $client = $this->getClient(); $em = $client->getContainer()->get('doctrine.orm.entity_manager');