X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FEntryControllerTest.php;h=3a8f92e7c4d86bc88d9dad55caff96b511486776;hb=8668796106b856ca041512af27268ce6e49d2caf;hp=005296ff33572c742db613f845289a37f7d43f19;hpb=c73025ad8b684de1ac21ba7583f1af6f1d185159;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 005296ff..3a8f92e7 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -13,7 +13,7 @@ class EntryControllerTest extends WallabagCoreTestCase { const AN_URL_CONTAINING_AN_ARTICLE_WITH_IMAGE = 'https://www.lemonde.fr/judo/article/2017/11/11/judo-la-decima-de-teddy-riner_5213605_1556020.html'; public $downloadImagesEnabled = false; - public $url = 'https://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'; + public $url = 'https://www.lemonde.fr/pixels/article/2019/06/18/ce-qu-il-faut-savoir-sur-le-libra-la-cryptomonnaie-de-facebook_5477887_4408996.html'; /** * @after @@ -164,9 +164,8 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); $this->assertSame($this->url, $content->getUrl()); - $this->assertContains('Google', $content->getTitle()); + $this->assertContains('la cryptomonnaie de Facebook', $content->getTitle()); $this->assertSame('fr', $content->getLanguage()); - $this->assertSame('2016-04-07 19:01:35', $content->getPublishedAt()->format('Y-m-d H:i:s')); $this->assertArrayHasKey('x-frame-options', $content->getHeaders()); $client->getContainer()->get('craue_config')->set('store_article_headers', 0); } @@ -200,8 +199,8 @@ class EntryControllerTest extends WallabagCoreTestCase $authors = $content->getPublishedBy(); $this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); $this->assertSame('fr', $content->getLanguage()); - $this->assertSame('Raphaël Balenieri, correspondant à Pékin', $authors[0]); - $this->assertSame('Frédéric Autran, correspondant à New York', $authors[1]); + $this->assertSame('Raphaël Balenieri', $authors[0]); + $this->assertSame('Frédéric Autran', $authors[1]); } public function testPostNewOkUrlExist() @@ -236,7 +235,45 @@ class EntryControllerTest extends WallabagCoreTestCase $this->logInAs('admin'); $client = $this->getClient(); - $url = 'http://www.aritylabs.com/post/106091708292/des-contr%C3%B4leurs-optionnels-gr%C3%A2ce-%C3%A0-constmissing'; + $url = 'https://www.aritylabs.com/post/106091708292/des-contr%C3%B4leurs-optionnels-gr%C3%A2ce-%C3%A0-constmissing'; + + $crawler = $client->request('GET', '/new'); + + $this->assertSame(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('form[name=entry]')->form(); + + $data = [ + 'entry[url]' => $url, + ]; + + $client->submit($form, $data); + + $crawler = $client->request('GET', '/new'); + + $this->assertSame(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('form[name=entry]')->form(); + + $data = [ + 'entry[url]' => $url, + ]; + + $client->submit($form, $data); + + $this->assertSame(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); + } + + /** + * This test will require an internet connection. + */ + public function testPostNewOkUrlExistWithRedirection() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $url = 'https://wllbg.org/test-redirect/c51c'; $crawler = $client->request('GET', '/new'); @@ -1340,7 +1377,7 @@ class EntryControllerTest extends WallabagCoreTestCase ], 'es-ES' => [ 'https://www.20minutos.es/noticia/3360685/0/gobierno-sanchez-primero-historia-mas-mujeres-que-hombres/', - 'es', + 'es_ES', ], ]; } @@ -1495,4 +1532,30 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertSame(sprintf('/remove-tag/%s/%s', $entry->getId(), $tag->getId()), $link); } + + public function testRandom() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $client->request('GET', '/unread/random'); + $this->assertSame(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Unread random'); + + $client->request('GET', '/starred/random'); + $this->assertSame(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Starred random'); + + $client->request('GET', '/archive/random'); + $this->assertSame(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Archive random'); + + $client->request('GET', '/untagged/random'); + $this->assertSame(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'Untagged random'); + + $client->request('GET', '/all/random'); + $this->assertSame(302, $client->getResponse()->getStatusCode()); + $this->assertContains('/view/', $client->getResponse()->getTargetUrl(), 'All random'); + } }