diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-03-21 12:47:57 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-03-21 12:47:57 +0100 |
commit | 439b36323e37f669b056cc5228c44bb91196256c (patch) | |
tree | ecd84477adf3e12819b26aff2a6d2e644e45ea72 /src/Wallabag/CoreBundle/Tests | |
parent | bd46de6b25f982e1a0d3f975971fe8014db13833 (diff) | |
parent | 4083887afe4dd3f568b2dfea3392506b554c79b8 (diff) | |
download | wallabag-439b36323e37f669b056cc5228c44bb91196256c.tar.gz wallabag-439b36323e37f669b056cc5228c44bb91196256c.tar.zst wallabag-439b36323e37f669b056cc5228c44bb91196256c.zip |
Merge pull request #1774 from wallabag/v2-key-translation
Switch to keys in translated files
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
4 files changed, 87 insertions, 77 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 51425fe1..f2d26750 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | |||
@@ -57,7 +57,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
57 | $crawler = $client->followRedirect(); | 57 | $crawler = $client->followRedirect(); |
58 | 58 | ||
59 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | 59 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); |
60 | $this->assertContains('Config saved', $alert[0]); | 60 | $this->assertContains('flashes.config.notice.config_saved', $alert[0]); |
61 | } | 61 | } |
62 | 62 | ||
63 | public function dataForUpdateFailed() | 63 | public function dataForUpdateFailed() |
@@ -102,7 +102,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
102 | 'change_passwd[new_password][first]' => '', | 102 | 'change_passwd[new_password][first]' => '', |
103 | 'change_passwd[new_password][second]' => '', | 103 | 'change_passwd[new_password][second]' => '', |
104 | ), | 104 | ), |
105 | 'Wrong value for your current password', | 105 | 'validator.password_wrong_value', |
106 | ), | 106 | ), |
107 | array( | 107 | array( |
108 | array( | 108 | array( |
@@ -118,7 +118,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
118 | 'change_passwd[new_password][first]' => 'hop', | 118 | 'change_passwd[new_password][first]' => 'hop', |
119 | 'change_passwd[new_password][second]' => '', | 119 | 'change_passwd[new_password][second]' => '', |
120 | ), | 120 | ), |
121 | 'The password fields must match', | 121 | 'validator.password_must_match', |
122 | ), | 122 | ), |
123 | array( | 123 | array( |
124 | array( | 124 | array( |
@@ -126,7 +126,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
126 | 'change_passwd[new_password][first]' => 'hop', | 126 | 'change_passwd[new_password][first]' => 'hop', |
127 | 'change_passwd[new_password][second]' => 'hop', | 127 | 'change_passwd[new_password][second]' => 'hop', |
128 | ), | 128 | ), |
129 | 'Password should by at least', | 129 | 'validator.password_too_short', |
130 | ), | 130 | ), |
131 | ); | 131 | ); |
132 | } | 132 | } |
@@ -177,7 +177,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
177 | $crawler = $client->followRedirect(); | 177 | $crawler = $client->followRedirect(); |
178 | 178 | ||
179 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | 179 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); |
180 | $this->assertContains('Password updated', $alert[0]); | 180 | $this->assertContains('flashes.config.notice.password_updated', $alert[0]); |
181 | } | 181 | } |
182 | 182 | ||
183 | public function dataForUserFailed() | 183 | public function dataForUserFailed() |
@@ -188,14 +188,14 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
188 | 'update_user[name]' => '', | 188 | 'update_user[name]' => '', |
189 | 'update_user[email]' => '', | 189 | 'update_user[email]' => '', |
190 | ), | 190 | ), |
191 | 'Please enter an email', | 191 | 'fos_user.email.blank', |
192 | ), | 192 | ), |
193 | array( | 193 | array( |
194 | array( | 194 | array( |
195 | 'update_user[name]' => '', | 195 | 'update_user[name]' => '', |
196 | 'update_user[email]' => 'test', | 196 | 'update_user[email]' => 'test', |
197 | ), | 197 | ), |
198 | 'The email is not valid', | 198 | 'fos_user.email.invalid', |
199 | ), | 199 | ), |
200 | ); | 200 | ); |
201 | } | 201 | } |
@@ -244,8 +244,8 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
244 | 244 | ||
245 | $crawler = $client->followRedirect(); | 245 | $crawler = $client->followRedirect(); |
246 | 246 | ||
247 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | 247 | $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text'))); |
248 | $this->assertContains('Information updated', $alert[0]); | 248 | $this->assertContains('flashes.config.notice.user_updated', $alert[0]); |
249 | } | 249 | } |
250 | 250 | ||
251 | public function dataForNewUserFailed() | 251 | public function dataForNewUserFailed() |
@@ -258,7 +258,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
258 | 'new_user[plainPassword][second]' => '', | 258 | 'new_user[plainPassword][second]' => '', |
259 | 'new_user[email]' => '', | 259 | 'new_user[email]' => '', |
260 | ), | 260 | ), |
261 | 'Please enter a username', | 261 | 'fos_user.username.blank', |
262 | ), | 262 | ), |
263 | array( | 263 | array( |
264 | array( | 264 | array( |
@@ -267,7 +267,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
267 | 'new_user[plainPassword][second]' => 'mypassword', | 267 | 'new_user[plainPassword][second]' => 'mypassword', |
268 | 'new_user[email]' => '', | 268 | 'new_user[email]' => '', |
269 | ), | 269 | ), |
270 | 'The username is too short', | 270 | 'fos_user.username.short', |
271 | ), | 271 | ), |
272 | array( | 272 | array( |
273 | array( | 273 | array( |
@@ -276,7 +276,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
276 | 'new_user[plainPassword][second]' => 'mypassword', | 276 | 'new_user[plainPassword][second]' => 'mypassword', |
277 | 'new_user[email]' => 'test', | 277 | 'new_user[email]' => 'test', |
278 | ), | 278 | ), |
279 | 'The email is not valid', | 279 | 'fos_user.email.invalid', |
280 | ), | 280 | ), |
281 | array( | 281 | array( |
282 | array( | 282 | array( |
@@ -285,7 +285,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
285 | 'new_user[plainPassword][second]' => 'wallacewallace', | 285 | 'new_user[plainPassword][second]' => 'wallacewallace', |
286 | 'new_user[email]' => 'wallace@wallace.me', | 286 | 'new_user[email]' => 'wallace@wallace.me', |
287 | ), | 287 | ), |
288 | 'The username is already used', | 288 | 'fos_user.username.already_used', |
289 | ), | 289 | ), |
290 | array( | 290 | array( |
291 | array( | 291 | array( |
@@ -294,7 +294,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
294 | 'new_user[plainPassword][second]' => 'mypassword2', | 294 | 'new_user[plainPassword][second]' => 'mypassword2', |
295 | 'new_user[email]' => 'wallace@wallace.me', | 295 | 'new_user[email]' => 'wallace@wallace.me', |
296 | ), | 296 | ), |
297 | 'The password fields must match', | 297 | 'validator.password_must_match', |
298 | ), | 298 | ), |
299 | ); | 299 | ); |
300 | } | 300 | } |
@@ -346,7 +346,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
346 | $crawler = $client->followRedirect(); | 346 | $crawler = $client->followRedirect(); |
347 | 347 | ||
348 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | 348 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); |
349 | $this->assertContains('User "wallace" added', $alert[0]); | 349 | $this->assertContains('flashes.config.notice.user_added', $alert[0]); |
350 | 350 | ||
351 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 351 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); |
352 | $user = $em | 352 | $user = $em |
@@ -382,7 +382,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
382 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 382 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
383 | 383 | ||
384 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); | 384 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
385 | $this->assertContains('You need to generate a token first.', $body[0]); | 385 | $this->assertContains('config.form_rss.no_token', $body[0]); |
386 | 386 | ||
387 | $client->request('GET', '/generate-token'); | 387 | $client->request('GET', '/generate-token'); |
388 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 388 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
@@ -390,7 +390,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
390 | $crawler = $client->followRedirect(); | 390 | $crawler = $client->followRedirect(); |
391 | 391 | ||
392 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); | 392 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
393 | $this->assertNotContains('You need to generate a token first.', $body[0]); | 393 | $this->assertNotContains('config.form_rss.no_token', $body[0]); |
394 | } | 394 | } |
395 | 395 | ||
396 | public function testGenerateTokenAjax() | 396 | public function testGenerateTokenAjax() |
@@ -418,11 +418,6 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
418 | 418 | ||
419 | $crawler = $client->request('GET', '/config'); | 419 | $crawler = $client->request('GET', '/config'); |
420 | 420 | ||
421 | if (500 == $client->getResponse()->getStatusCode()) { | ||
422 | var_export($client->getResponse()->getContent()); | ||
423 | die(); | ||
424 | } | ||
425 | |||
426 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 421 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
427 | 422 | ||
428 | $form = $crawler->filter('button[id=rss_config_save]')->form(); | 423 | $form = $crawler->filter('button[id=rss_config_save]')->form(); |
@@ -438,7 +433,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
438 | $crawler = $client->followRedirect(); | 433 | $crawler = $client->followRedirect(); |
439 | 434 | ||
440 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | 435 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); |
441 | $this->assertContains('RSS information updated', $alert[0]); | 436 | $this->assertContains('flashes.config.notice.rss_updated', $alert[0]); |
442 | } | 437 | } |
443 | 438 | ||
444 | public function dataForRssFailed() | 439 | public function dataForRssFailed() |
@@ -454,7 +449,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
454 | array( | 449 | array( |
455 | 'rss_config[rss_limit]' => 1000000000000, | 450 | 'rss_config[rss_limit]' => 1000000000000, |
456 | ), | 451 | ), |
457 | 'This will certainly kill the app', | 452 | 'validator.rss_limit_too_hight', |
458 | ), | 453 | ), |
459 | ); | 454 | ); |
460 | } | 455 | } |
@@ -504,7 +499,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
504 | $crawler = $client->followRedirect(); | 499 | $crawler = $client->followRedirect(); |
505 | 500 | ||
506 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | 501 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); |
507 | $this->assertContains('Tagging rules updated', $alert[0]); | 502 | $this->assertContains('flashes.config.notice.tagging_rules_updated', $alert[0]); |
508 | 503 | ||
509 | $deleteLink = $crawler->filter('.delete')->last()->link(); | 504 | $deleteLink = $crawler->filter('.delete')->last()->link(); |
510 | 505 | ||
@@ -513,7 +508,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
513 | 508 | ||
514 | $crawler = $client->followRedirect(); | 509 | $crawler = $client->followRedirect(); |
515 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); | 510 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.messages.success')->extract(array('_text'))); |
516 | $this->assertContains('Tagging rule deleted', $alert[0]); | 511 | $this->assertContains('flashes.config.notice.tagging_rules_deleted', $alert[0]); |
517 | } | 512 | } |
518 | 513 | ||
519 | public function dataForTaggingRuleFailed() | 514 | public function dataForTaggingRuleFailed() |
@@ -556,12 +551,14 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
556 | 551 | ||
557 | $form = $crawler->filter('button[id=tagging_rule_save]')->form(); | 552 | $form = $crawler->filter('button[id=tagging_rule_save]')->form(); |
558 | 553 | ||
559 | $client->submit($form, $data); | 554 | $crawler = $client->submit($form, $data); |
560 | 555 | ||
561 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 556 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
562 | 557 | ||
558 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); | ||
559 | |||
563 | foreach ($messages as $message) { | 560 | foreach ($messages as $message) { |
564 | $this->assertContains($message, $client->getResponse()->getContent()); | 561 | $this->assertContains($message, $body[0]); |
565 | } | 562 | } |
566 | } | 563 | } |
567 | 564 | ||
@@ -574,9 +571,11 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
574 | ->getRepository('WallabagCoreBundle:TaggingRule') | 571 | ->getRepository('WallabagCoreBundle:TaggingRule') |
575 | ->findAll()[0]; | 572 | ->findAll()[0]; |
576 | 573 | ||
577 | $client->request('GET', '/tagging-rule/delete/'.$rule->getId()); | 574 | $crawler = $client->request('GET', '/tagging-rule/delete/'.$rule->getId()); |
575 | |||
578 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | 576 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); |
579 | $this->assertContains('You can not access this tagging ryle', $client->getResponse()->getContent()); | 577 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
578 | $this->assertContains('You can not access this tagging rule', $body[0]); | ||
580 | } | 579 | } |
581 | 580 | ||
582 | public function testDemoMode() | 581 | public function testDemoMode() |
@@ -603,7 +602,7 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
603 | $client->submit($form, $data); | 602 | $client->submit($form, $data); |
604 | 603 | ||
605 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 604 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
606 | $this->assertContains('In demonstration mode, you can\'t change password for this user.', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); | 605 | $this->assertContains('flashes.config.notice.password_not_updated_demo', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); |
607 | 606 | ||
608 | $config->set('demo_mode_enabled', 0); | 607 | $config->set('demo_mode_enabled', 0); |
609 | $config->set('demo_mode_username', 'wallabag'); | 608 | $config->set('demo_mode_username', 'wallabag'); |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 5512d6e1..46fbaf91 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -25,17 +25,18 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
25 | $client = $this->getClient(); | 25 | $client = $this->getClient(); |
26 | 26 | ||
27 | $client->request('GET', '/unread/list'); | 27 | $client->request('GET', '/unread/list'); |
28 | $client->followRedirect(); | 28 | $crawler = $client->followRedirect(); |
29 | 29 | ||
30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 30 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
31 | $this->assertContains('We\'ll accompany you to visit wallabag', $client->getResponse()->getContent()); | 31 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
32 | $this->assertContains('quickstart.intro.paragraph_1', $body[0]); | ||
32 | 33 | ||
33 | // Test if quickstart is disabled when user has 1 entry | 34 | // Test if quickstart is disabled when user has 1 entry |
34 | $crawler = $client->request('GET', '/new'); | 35 | $crawler = $client->request('GET', '/new'); |
35 | 36 | ||
36 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 37 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
37 | 38 | ||
38 | $form = $crawler->filter('button[type=submit]')->form(); | 39 | $form = $crawler->filter('form[name=entry]')->form(); |
39 | 40 | ||
40 | $data = array( | 41 | $data = array( |
41 | 'entry[url]' => $this->url, | 42 | 'entry[url]' => $this->url, |
@@ -45,8 +46,9 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
45 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 46 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
46 | $client->followRedirect(); | 47 | $client->followRedirect(); |
47 | 48 | ||
48 | $client->request('GET', '/unread/list'); | 49 | $crawler = $client->request('GET', '/unread/list'); |
49 | $this->assertContains('There is one entry.', $client->getResponse()->getContent()); | 50 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
51 | $this->assertContains('entry.list.number_on_the_page', $body[0]); | ||
50 | } | 52 | } |
51 | 53 | ||
52 | public function testGetNew() | 54 | public function testGetNew() |
@@ -59,7 +61,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
59 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 61 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
60 | 62 | ||
61 | $this->assertCount(1, $crawler->filter('input[type=url]')); | 63 | $this->assertCount(1, $crawler->filter('input[type=url]')); |
62 | $this->assertCount(1, $crawler->filter('button[type=submit]')); | 64 | $this->assertCount(1, $crawler->filter('form[name=entry]')); |
63 | } | 65 | } |
64 | 66 | ||
65 | public function testPostNewViaBookmarklet() | 67 | public function testPostNewViaBookmarklet() |
@@ -96,7 +98,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
96 | 98 | ||
97 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 99 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
98 | 100 | ||
99 | $form = $crawler->filter('button[type=submit]')->form(); | 101 | $form = $crawler->filter('form[name=entry]')->form(); |
100 | 102 | ||
101 | $crawler = $client->submit($form); | 103 | $crawler = $client->submit($form); |
102 | 104 | ||
@@ -117,7 +119,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
117 | 119 | ||
118 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 120 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
119 | 121 | ||
120 | $form = $crawler->filter('button[type=submit]')->form(); | 122 | $form = $crawler->filter('form[name=entry]')->form(); |
121 | 123 | ||
122 | $data = array( | 124 | $data = array( |
123 | 'entry[url]' => $this->url, | 125 | 'entry[url]' => $this->url, |
@@ -146,7 +148,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
146 | 148 | ||
147 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 149 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
148 | 150 | ||
149 | $form = $crawler->filter('button[type=submit]')->form(); | 151 | $form = $crawler->filter('form[name=entry]')->form(); |
150 | 152 | ||
151 | $data = array( | 153 | $data = array( |
152 | 'entry[url]' => $this->url, | 154 | 'entry[url]' => $this->url, |
@@ -170,7 +172,7 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
170 | 172 | ||
171 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 173 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
172 | 174 | ||
173 | $form = $crawler->filter('button[type=submit]')->form(); | 175 | $form = $crawler->filter('form[name=entry]')->form(); |
174 | 176 | ||
175 | $data = array( | 177 | $data = array( |
176 | 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', | 178 | 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', |
@@ -240,10 +242,11 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
240 | ->getRepository('WallabagCoreBundle:Entry') | 242 | ->getRepository('WallabagCoreBundle:Entry') |
241 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); | 243 | ->findByUrlAndUserId($this->url, $this->getLoggedInUserId()); |
242 | 244 | ||
243 | $client->request('GET', '/view/'.$content->getId()); | 245 | $crawler = $client->request('GET', '/view/'.$content->getId()); |
244 | 246 | ||
245 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | 247 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); |
246 | $this->assertContains($content->getTitle(), $client->getResponse()->getContent()); | 248 | $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(array('_text'))); |
249 | $this->assertContains($content->getTitle(), $body[0]); | ||
247 | } | 250 | } |
248 | 251 | ||
249 | /** | 252 | /** |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php index b9f5d835..ed292633 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | |||
@@ -12,53 +12,61 @@ class SecurityControllerTest extends WallabagCoreTestCase | |||
12 | $client = $this->getClient(); | 12 | $client = $this->getClient(); |
13 | $client->followRedirects(); | 13 | $client->followRedirects(); |
14 | 14 | ||
15 | $client->request('GET', '/config'); | 15 | $crawler = $client->request('GET', '/config'); |
16 | $this->assertContains('RSS', $client->getResponse()->getContent()); | 16 | $this->assertContains('config.form_rss.description', $crawler->filter('body')->extract(array('_text'))[0]); |
17 | } | 17 | } |
18 | 18 | ||
19 | public function testLoginWith2Factor() | 19 | public function testLoginWith2Factor() |
20 | { | 20 | { |
21 | $client = $this->getClient(); | 21 | $client = $this->getClient(); |
22 | 22 | ||
23 | if ($client->getContainer()->getParameter('twofactor_auth')) { | 23 | if (!$client->getContainer()->getParameter('twofactor_auth')) { |
24 | $client->followRedirects(); | 24 | $this->markTestSkipped('twofactor_auth is not enabled.'); |
25 | 25 | ||
26 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 26 | return; |
27 | $user = $em | ||
28 | ->getRepository('WallabagUserBundle:User') | ||
29 | ->findOneByUsername('admin'); | ||
30 | $user->setTwoFactorAuthentication(true); | ||
31 | $em->persist($user); | ||
32 | $em->flush(); | ||
33 | |||
34 | $this->logInAs('admin'); | ||
35 | $client->request('GET', '/config'); | ||
36 | $this->assertContains('trusted computer', $client->getResponse()->getContent()); | ||
37 | |||
38 | // restore user | ||
39 | $user = $em | ||
40 | ->getRepository('WallabagUserBundle:User') | ||
41 | ->findOneByUsername('admin'); | ||
42 | $user->setTwoFactorAuthentication(false); | ||
43 | $em->persist($user); | ||
44 | $em->flush(); | ||
45 | } | 27 | } |
28 | |||
29 | $client->followRedirects(); | ||
30 | |||
31 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
32 | $user = $em | ||
33 | ->getRepository('WallabagUserBundle:User') | ||
34 | ->findOneByUsername('admin'); | ||
35 | $user->setTwoFactorAuthentication(true); | ||
36 | $em->persist($user); | ||
37 | $em->flush(); | ||
38 | |||
39 | $this->logInAs('admin'); | ||
40 | $crawler = $client->request('GET', '/config'); | ||
41 | $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(array('_text'))[0]); | ||
42 | |||
43 | // restore user | ||
44 | $user = $em | ||
45 | ->getRepository('WallabagUserBundle:User') | ||
46 | ->findOneByUsername('admin'); | ||
47 | $user->setTwoFactorAuthentication(false); | ||
48 | $em->persist($user); | ||
49 | $em->flush(); | ||
46 | } | 50 | } |
47 | 51 | ||
48 | public function testTrustedComputer() | 52 | public function testTrustedComputer() |
49 | { | 53 | { |
50 | $client = $this->getClient(); | 54 | $client = $this->getClient(); |
51 | 55 | ||
52 | if ($client->getContainer()->getParameter('twofactor_auth')) { | 56 | if (!$client->getContainer()->getParameter('twofactor_auth')) { |
53 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 57 | $this->markTestSkipped('twofactor_auth is not enabled.'); |
54 | $user = $em | ||
55 | ->getRepository('WallabagUserBundle:User') | ||
56 | ->findOneByUsername('admin'); | ||
57 | 58 | ||
58 | $date = new \DateTime(); | 59 | return; |
59 | $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); | ||
60 | $this->assertTrue($user->isTrustedComputer('ABCDEF')); | ||
61 | $this->assertFalse($user->isTrustedComputer('FEDCBA')); | ||
62 | } | 60 | } |
61 | |||
62 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | ||
63 | $user = $em | ||
64 | ->getRepository('WallabagUserBundle:User') | ||
65 | ->findOneByUsername('admin'); | ||
66 | |||
67 | $date = new \DateTime(); | ||
68 | $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M'))); | ||
69 | $this->assertTrue($user->isTrustedComputer('ABCDEF')); | ||
70 | $this->assertFalse($user->isTrustedComputer('FEDCBA')); | ||
63 | } | 71 | } |
64 | } | 72 | } |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php index d6391282..338121e7 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php | |||
@@ -30,7 +30,7 @@ class TagControllerTest extends WallabagCoreTestCase | |||
30 | 30 | ||
31 | $crawler = $client->request('GET', '/view/'.$entry->getId()); | 31 | $crawler = $client->request('GET', '/view/'.$entry->getId()); |
32 | 32 | ||
33 | $form = $crawler->filter('button[id=tag_save]')->form(); | 33 | $form = $crawler->filter('form[name=tag]')->form(); |
34 | 34 | ||
35 | $data = array( | 35 | $data = array( |
36 | 'tag[label]' => $this->tagName, | 36 | 'tag[label]' => $this->tagName, |