diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | 61 |
1 files changed, 30 insertions, 31 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'); |