aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-06-09 11:28:04 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-06-09 11:28:04 +0200
commit42f3bb2c6346e04d2837f980bf685f7e32a61a21 (patch)
tree7d419190ff7f5cd0bf3b94168ff614a5ebdd93a3 /tests
parente9056dd96f9e8c2e06b5752b8de767bbedfc71ea (diff)
downloadwallabag-42f3bb2c6346e04d2837f980bf685f7e32a61a21.tar.gz
wallabag-42f3bb2c6346e04d2837f980bf685f7e32a61a21.tar.zst
wallabag-42f3bb2c6346e04d2837f980bf685f7e32a61a21.zip
Use Locale instead of Language
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php92
1 files changed, 78 insertions, 14 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index cc7b3672..b77e5ec1 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -158,6 +158,7 @@ class EntryControllerTest extends WallabagCoreTestCase
158 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); 158 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
159 $this->assertEquals($this->url, $content->getUrl()); 159 $this->assertEquals($this->url, $content->getUrl());
160 $this->assertContains('Google', $content->getTitle()); 160 $this->assertContains('Google', $content->getTitle());
161 $this->assertEquals('fr', $content->getLanguage());
161 $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s')); 162 $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
162 $this->assertEquals('Morgane Tual', $author[0]); 163 $this->assertEquals('Morgane Tual', $author[0]);
163 $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); 164 $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
@@ -190,6 +191,7 @@ class EntryControllerTest extends WallabagCoreTestCase
190 191
191 $authors = $content->getPublishedBy(); 192 $authors = $content->getPublishedBy();
192 $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); 193 $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
194 $this->assertEquals('fr', $content->getLanguage());
193 $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]); 195 $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
194 $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]); 196 $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]);
195 } 197 }
@@ -254,15 +256,6 @@ class EntryControllerTest extends WallabagCoreTestCase
254 256
255 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 257 $this->assertEquals(302, $client->getResponse()->getStatusCode());
256 $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); 258 $this->assertContains('/view/', $client->getResponse()->getTargetUrl());
257
258 $em = $client->getContainer()
259 ->get('doctrine.orm.entity_manager');
260 $entry = $em
261 ->getRepository('WallabagCoreBundle:Entry')
262 ->findOneByUrl(urldecode($url));
263
264 $em->remove($entry);
265 $em->flush();
266 } 259 }
267 260
268 /** 261 /**
@@ -297,6 +290,7 @@ class EntryControllerTest extends WallabagCoreTestCase
297 290
298 $this->assertCount(2, $tags); 291 $this->assertCount(2, $tags);
299 $this->assertContains('wallabag', $tags); 292 $this->assertContains('wallabag', $tags);
293 $this->assertEquals('en', $entry->getLanguage());
300 294
301 $em->remove($entry); 295 $em->remove($entry);
302 $em->flush(); 296 $em->flush();
@@ -392,8 +386,6 @@ class EntryControllerTest extends WallabagCoreTestCase
392 } 386 }
393 387
394 /** 388 /**
395 * @depends testPostNewOk
396 *
397 * This test will require an internet connection. 389 * This test will require an internet connection.
398 */ 390 */
399 public function testReload() 391 public function testReload()
@@ -420,9 +412,6 @@ class EntryControllerTest extends WallabagCoreTestCase
420 $this->assertNotEmpty($entry->getContent()); 412 $this->assertNotEmpty($entry->getContent());
421 } 413 }
422 414
423 /**
424 * @depends testPostNewOk
425 */
426 public function testReloadWithFetchingFailed() 415 public function testReloadWithFetchingFailed()
427 { 416 {
428 $this->logInAs('admin'); 417 $this->logInAs('admin');
@@ -1001,6 +990,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1001 $this->assertContains('Perpignan', $entry->getTitle()); 990 $this->assertContains('Perpignan', $entry->getTitle());
1002 // instead of checking for the filename (which might change) check that the image is now local 991 // instead of checking for the filename (which might change) check that the image is now local
1003 $this->assertContains('http://v2.wallabag.org/assets/images/', $entry->getContent()); 992 $this->assertContains('http://v2.wallabag.org/assets/images/', $entry->getContent());
993 $this->assertEquals('fr', $entry->getLanguage());
1004 994
1005 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); 995 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
1006 } 996 }
@@ -1254,4 +1244,78 @@ class EntryControllerTest extends WallabagCoreTestCase
1254 1244
1255 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1245 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1256 } 1246 }
1247
1248 public function dataForLanguage()
1249 {
1250 return [
1251 'ru' => [
1252 'https://www.pravda.ru/world/09-06-2017/1337283-qatar-0/',
1253 'ru',
1254 ],
1255 'wrong fr-FR' => [
1256 'http://www.zataz.com/fff-darknet/axzz4jUg2QJjH',
1257 '',
1258 ],
1259 'de' => [
1260 'http://www.bild.de/politik/ausland/theresa-may/wahlbeben-grossbritannien-analyse-52108924.bild.html',
1261 'de',
1262 ],
1263 'it' => [
1264 'http://www.ansa.it/sito/notizie/mondo/europa/2017/06/08/voto-gb-seggi-aperti-misure-sicurezza-rafforzate_0cb71f7f-e23b-4d5f-95ca-bc12296419f0.html',
1265 'it',
1266 ],
1267 'zh_CN' => [
1268 'http://www.hao123.com/shequ?__noscript__-=1',
1269 'zh_CN',
1270 ],
1271 'de_AT' => [
1272 'https://buy.garmin.com/de-AT/AT/catalog/product/compareResult.ep?compareProduct=112885&compareProduct=36728',
1273 'de_AT',
1274 ],
1275 'ru_RU' => [
1276 'http://netler.ru/ikt/windows-error-reporting.htm',
1277 'ru_RU',
1278 ],
1279 'pt_BR' => [
1280 'http://precodoscombustiveis.com.br/postos/cidade/4121/pr/maringa',
1281 'pt_BR',
1282 ],
1283 'fucked list of languages' => [
1284 'http://geocatalog.webservice-energy.org/geonetwork/srv/eng/main.home',
1285 '',
1286 ],
1287 ];
1288 }
1289
1290 /**
1291 * @dataProvider dataForLanguage
1292 */
1293 public function testLanguageValidation($url, $expectedLanguage)
1294 {
1295 $this->logInAs('admin');
1296 $client = $this->getClient();
1297
1298 $crawler = $client->request('GET', '/new');
1299
1300 $this->assertEquals(200, $client->getResponse()->getStatusCode());
1301
1302 $form = $crawler->filter('form[name=entry]')->form();
1303
1304 $data = [
1305 'entry[url]' => $url,
1306 ];
1307
1308 $client->submit($form, $data);
1309
1310 $this->assertEquals(302, $client->getResponse()->getStatusCode());
1311
1312 $content = $client->getContainer()
1313 ->get('doctrine.orm.entity_manager')
1314 ->getRepository('WallabagCoreBundle:Entry')
1315 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1316
1317 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
1318 $this->assertEquals($url, $content->getUrl());
1319 $this->assertEquals($expectedLanguage, $content->getLanguage());
1320 }
1257} 1321}