aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php28
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php16
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php70
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/TagControllerTest.php2
4 files changed, 61 insertions, 55 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index 51425fe1..bf455f32 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -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 }
@@ -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,7 +244,7 @@ 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('Information updated', $alert[0]);
249 } 249 }
250 250
@@ -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 }
@@ -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()
@@ -454,7 +454,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
454 array( 454 array(
455 'rss_config[rss_limit]' => 1000000000000, 455 'rss_config[rss_limit]' => 1000000000000,
456 ), 456 ),
457 'This will certainly kill the app', 457 'validator.rss_limit_too_hight',
458 ), 458 ),
459 ); 459 );
460 } 460 }
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 5512d6e1..0fcf323c 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -28,14 +28,14 @@ class EntryControllerTest extends WallabagCoreTestCase
28 $client->followRedirect(); 28 $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->assertContains('quickstart.intro.paragraph_1', $client->getResponse()->getContent());
32 32
33 // Test if quickstart is disabled when user has 1 entry 33 // Test if quickstart is disabled when user has 1 entry
34 $crawler = $client->request('GET', '/new'); 34 $crawler = $client->request('GET', '/new');
35 35
36 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 36 $this->assertEquals(200, $client->getResponse()->getStatusCode());
37 37
38 $form = $crawler->filter('button[type=submit]')->form(); 38 $form = $crawler->filter('form[name=entry]')->form();
39 39
40 $data = array( 40 $data = array(
41 'entry[url]' => $this->url, 41 'entry[url]' => $this->url,
@@ -46,7 +46,7 @@ class EntryControllerTest extends WallabagCoreTestCase
46 $client->followRedirect(); 46 $client->followRedirect();
47 47
48 $client->request('GET', '/unread/list'); 48 $client->request('GET', '/unread/list');
49 $this->assertContains('There is one entry.', $client->getResponse()->getContent()); 49 $this->assertContains('entry.list.number_on_the_page', $client->getResponse()->getContent());
50 } 50 }
51 51
52 public function testGetNew() 52 public function testGetNew()
@@ -59,7 +59,7 @@ class EntryControllerTest extends WallabagCoreTestCase
59 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 59 $this->assertEquals(200, $client->getResponse()->getStatusCode());
60 60
61 $this->assertCount(1, $crawler->filter('input[type=url]')); 61 $this->assertCount(1, $crawler->filter('input[type=url]'));
62 $this->assertCount(1, $crawler->filter('button[type=submit]')); 62 $this->assertCount(1, $crawler->filter('form[name=entry]'));
63 } 63 }
64 64
65 public function testPostNewViaBookmarklet() 65 public function testPostNewViaBookmarklet()
@@ -96,7 +96,7 @@ class EntryControllerTest extends WallabagCoreTestCase
96 96
97 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 97 $this->assertEquals(200, $client->getResponse()->getStatusCode());
98 98
99 $form = $crawler->filter('button[type=submit]')->form(); 99 $form = $crawler->filter('form[name=entry]')->form();
100 100
101 $crawler = $client->submit($form); 101 $crawler = $client->submit($form);
102 102
@@ -117,7 +117,7 @@ class EntryControllerTest extends WallabagCoreTestCase
117 117
118 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 118 $this->assertEquals(200, $client->getResponse()->getStatusCode());
119 119
120 $form = $crawler->filter('button[type=submit]')->form(); 120 $form = $crawler->filter('form[name=entry]')->form();
121 121
122 $data = array( 122 $data = array(
123 'entry[url]' => $this->url, 123 'entry[url]' => $this->url,
@@ -146,7 +146,7 @@ class EntryControllerTest extends WallabagCoreTestCase
146 146
147 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 147 $this->assertEquals(200, $client->getResponse()->getStatusCode());
148 148
149 $form = $crawler->filter('button[type=submit]')->form(); 149 $form = $crawler->filter('form[name=entry]')->form();
150 150
151 $data = array( 151 $data = array(
152 'entry[url]' => $this->url, 152 'entry[url]' => $this->url,
@@ -170,7 +170,7 @@ class EntryControllerTest extends WallabagCoreTestCase
170 170
171 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 171 $this->assertEquals(200, $client->getResponse()->getStatusCode());
172 172
173 $form = $crawler->filter('button[type=submit]')->form(); 173 $form = $crawler->filter('form[name=entry]')->form();
174 174
175 $data = array( 175 $data = array(
176 'entry[url]' => $url = 'https://github.com/wallabag/wallabag', 176 'entry[url]' => $url = 'https://github.com/wallabag/wallabag',
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
index b9f5d835..5c098cc2 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php
@@ -12,53 +12,59 @@ 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 return;
26 }
25 27
26 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 28 $client->followRedirects();
27 $user = $em
28 ->getRepository('WallabagUserBundle:User')
29 ->findOneByUsername('admin');
30 $user->setTwoFactorAuthentication(true);
31 $em->persist($user);
32 $em->flush();
33 29
34 $this->logInAs('admin'); 30 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
35 $client->request('GET', '/config'); 31 $user = $em
36 $this->assertContains('trusted computer', $client->getResponse()->getContent()); 32 ->getRepository('WallabagUserBundle:User')
33 ->findOneByUsername('admin');
34 $user->setTwoFactorAuthentication(true);
35 $em->persist($user);
36 $em->flush();
37 37
38 // restore user 38 $this->logInAs('admin');
39 $user = $em 39 $crawler = $client->request('GET', '/config');
40 ->getRepository('WallabagUserBundle:User') 40 $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(array('_text'))[0]);
41 ->findOneByUsername('admin'); 41
42 $user->setTwoFactorAuthentication(false); 42 // restore user
43 $em->persist($user); 43 $user = $em
44 $em->flush(); 44 ->getRepository('WallabagUserBundle:User')
45 } 45 ->findOneByUsername('admin');
46 $user->setTwoFactorAuthentication(false);
47 $em->persist($user);
48 $em->flush();
46 } 49 }
47 50
48 public function testTrustedComputer() 51 public function testTrustedComputer()
49 { 52 {
50 $client = $this->getClient(); 53 $client = $this->getClient();
51 54
52 if ($client->getContainer()->getParameter('twofactor_auth')) { 55 if (!$client->getContainer()->getParameter('twofactor_auth')) {
53 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 56 $this->markTestSkipped('twofactor_auth is not enabled.');
54 $user = $em 57 return;
55 ->getRepository('WallabagUserBundle:User')
56 ->findOneByUsername('admin');
57
58 $date = new \DateTime();
59 $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
60 $this->assertTrue($user->isTrustedComputer('ABCDEF'));
61 $this->assertFalse($user->isTrustedComputer('FEDCBA'));
62 } 58 }
59
60 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
61 $user = $em
62 ->getRepository('WallabagUserBundle:User')
63 ->findOneByUsername('admin');
64
65 $date = new \DateTime();
66 $user->addTrustedComputer('ABCDEF', $date->add(new \DateInterval('P1M')));
67 $this->assertTrue($user->isTrustedComputer('ABCDEF'));
68 $this->assertFalse($user->isTrustedComputer('FEDCBA'));
63 } 69 }
64} 70}
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,