X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FCoreBundle%2FController%2FEntryControllerTest.php;h=8f5c372d83bc92356b2ab8e9daec60fb371a3640;hb=873f6b8e03079d11fab541aa5b0bc6f8fe2d645e;hp=cc7b3672c73e6ddc98f6d7ce33a73c7cbdae52ee;hpb=590151680538ea1edfef9053da476cd92c6944c4;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index cc7b3672..8f5c372d 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php @@ -158,6 +158,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); $this->assertEquals($this->url, $content->getUrl()); $this->assertContains('Google', $content->getTitle()); + $this->assertEquals('fr', $content->getLanguage()); $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s')); $this->assertEquals('Morgane Tual', $author[0]); $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); @@ -190,6 +191,7 @@ class EntryControllerTest extends WallabagCoreTestCase $authors = $content->getPublishedBy(); $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); + $this->assertEquals('fr', $content->getLanguage()); $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]); $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]); } @@ -254,15 +256,6 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals(302, $client->getResponse()->getStatusCode()); $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); - - $em = $client->getContainer() - ->get('doctrine.orm.entity_manager'); - $entry = $em - ->getRepository('WallabagCoreBundle:Entry') - ->findOneByUrl(urldecode($url)); - - $em->remove($entry); - $em->flush(); } /** @@ -297,6 +290,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(2, $tags); $this->assertContains('wallabag', $tags); + $this->assertEquals('en', $entry->getLanguage()); $em->remove($entry); $em->flush(); @@ -392,8 +386,6 @@ class EntryControllerTest extends WallabagCoreTestCase } /** - * @depends testPostNewOk - * * This test will require an internet connection. */ public function testReload() @@ -420,9 +412,6 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertNotEmpty($entry->getContent()); } - /** - * @depends testPostNewOk - */ public function testReloadWithFetchingFailed() { $this->logInAs('admin'); @@ -1000,7 +989,7 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertEquals($url, $entry->getUrl()); $this->assertContains('Perpignan', $entry->getTitle()); // instead of checking for the filename (which might change) check that the image is now local - $this->assertContains('http://v2.wallabag.org/assets/images/', $entry->getContent()); + $this->assertContains('https://your-wallabag-url-instance.com/assets/images/', $entry->getContent()); $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); } @@ -1254,4 +1243,82 @@ class EntryControllerTest extends WallabagCoreTestCase $this->assertCount(1, $crawler->filter('div[class=entry]')); } + + public function dataForLanguage() + { + return [ + 'ru' => [ + 'https://www.pravda.ru/world/09-06-2017/1337283-qatar-0/', + 'ru', + ], + 'fr-FR' => [ + 'http://www.zataz.com/90-des-dossiers-medicaux-des-coreens-du-sud-vendus-a-des-entreprises-privees/', + 'fr_FR', + ], + 'de' => [ + 'http://www.bild.de/politik/ausland/theresa-may/wahlbeben-grossbritannien-analyse-52108924.bild.html', + 'de', + ], + 'it' => [ + 'http://www.ansa.it/sito/notizie/mondo/europa/2017/06/08/voto-gb-seggi-aperti-misure-sicurezza-rafforzate_0cb71f7f-e23b-4d5f-95ca-bc12296419f0.html', + 'it', + ], + 'zh_CN' => [ + 'http://www.hao123.com/shequ?__noscript__-=1', + 'zh_CN', + ], + 'de_AT' => [ + 'https://buy.garmin.com/de-AT/AT/catalog/product/compareResult.ep?compareProduct=112885&compareProduct=36728', + 'de_AT', + ], + 'ru_RU' => [ + 'http://netler.ru/ikt/windows-error-reporting.htm', + 'ru_RU', + ], + 'pt_BR' => [ + 'http://precodoscombustiveis.com.br/postos/cidade/4121/pr/maringa', + 'pt_BR', + ], + 'fucked_list_of_languages' => [ + 'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home', + '', + ], + 'es-ES' => [ + 'http://www.muylinux.com/2015/04/17/odf-reino-unido-microsoft-google', + 'es_ES', + ], + ]; + } + + /** + * @dataProvider dataForLanguage + */ + public function testLanguageValidation($url, $expectedLanguage) + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/new'); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $form = $crawler->filter('form[name=entry]')->form(); + + $data = [ + 'entry[url]' => $url, + ]; + + $client->submit($form, $data); + + $this->assertEquals(302, $client->getResponse()->getStatusCode()); + + $content = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findByUrlAndUserId($url, $this->getLoggedInUserId()); + + $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); + $this->assertEquals($url, $content->getUrl()); + $this->assertEquals($expectedLanguage, $content->getLanguage()); + } }