aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-02-17 21:03:23 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-02-17 21:03:23 +0100
commitd9085c63e35bb708f560722fff5f4f5ad322c27b (patch)
tree73e2183afe218442ce44faffe469e31f630d89d9 /src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
parent7781faa0b0749b0d9842fddec3e337db04d44a10 (diff)
downloadwallabag-d9085c63e35bb708f560722fff5f4f5ad322c27b.tar.gz
wallabag-d9085c63e35bb708f560722fff5f4f5ad322c27b.tar.zst
wallabag-d9085c63e35bb708f560722fff5f4f5ad322c27b.zip
Handle password change
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php94
1 files changed, 91 insertions, 3 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index 30809a04..4aceed15 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -26,7 +26,8 @@ class ConfigControllerTest extends WallabagTestCase
26 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 26 $this->assertEquals(200, $client->getResponse()->getStatusCode());
27 27
28 $this->assertCount(1, $crawler->filter('input[type=number]')); 28 $this->assertCount(1, $crawler->filter('input[type=number]'));
29 $this->assertCount(1, $crawler->filter('button[type=submit]')); 29 $this->assertCount(1, $crawler->filter('button[id=config_save]'));
30 $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]'));
30 } 31 }
31 32
32 public function testUpdate() 33 public function testUpdate()
@@ -38,7 +39,7 @@ class ConfigControllerTest extends WallabagTestCase
38 39
39 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 40 $this->assertEquals(200, $client->getResponse()->getStatusCode());
40 41
41 $form = $crawler->filter('button[type=submit]')->form(); 42 $form = $crawler->filter('button[id=config_save]')->form();
42 43
43 $data = array( 44 $data = array(
44 'config[theme]' => 'baggy', 45 'config[theme]' => 'baggy',
@@ -84,7 +85,7 @@ class ConfigControllerTest extends WallabagTestCase
84 85
85 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 86 $this->assertEquals(200, $client->getResponse()->getStatusCode());
86 87
87 $form = $crawler->filter('button[type=submit]')->form(); 88 $form = $crawler->filter('button[id=config_save]')->form();
88 89
89 $crawler = $client->submit($form, $data); 90 $crawler = $client->submit($form, $data);
90 91
@@ -93,4 +94,91 @@ class ConfigControllerTest extends WallabagTestCase
93 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text'))); 94 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
94 $this->assertContains('This value should not be blank', $alert[0]); 95 $this->assertContains('This value should not be blank', $alert[0]);
95 } 96 }
97
98 public function dataForChangePasswordFailed()
99 {
100 return array(
101 array(
102 array(
103 'change_passwd[old_password]' => 'baggy',
104 'change_passwd[new_password][first]' => '',
105 'change_passwd[new_password][second]' => '',
106 ),
107 'Wrong value for your current password'
108 ),
109 array(
110 array(
111 'change_passwd[old_password]' => 'mypassword',
112 'change_passwd[new_password][first]' => '',
113 'change_passwd[new_password][second]' => '',
114 ),
115 'This value should not be blank'
116 ),
117 array(
118 array(
119 'change_passwd[old_password]' => 'mypassword',
120 'change_passwd[new_password][first]' => 'hop',
121 'change_passwd[new_password][second]' => '',
122 ),
123 'The password fields must match'
124 ),
125 array(
126 array(
127 'change_passwd[old_password]' => 'mypassword',
128 'change_passwd[new_password][first]' => 'hop',
129 'change_passwd[new_password][second]' => 'hop',
130 ),
131 'Password should by at least 6 chars long'
132 ),
133 );
134 }
135
136 /**
137 * @dataProvider dataForChangePasswordFailed
138 */
139 public function testChangePasswordFailed($data, $expectedMessage)
140 {
141 $this->logInAs('admin');
142 $client = $this->getClient();
143
144 $crawler = $client->request('GET', '/config');
145
146 $this->assertEquals(200, $client->getResponse()->getStatusCode());
147
148 $form = $crawler->filter('button[id=change_passwd_save]')->form();
149
150 $crawler = $client->submit($form, $data);
151
152 $this->assertEquals(200, $client->getResponse()->getStatusCode());
153
154 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
155 $this->assertContains($expectedMessage, $alert[0]);
156 }
157
158 public function testChangePassword()
159 {
160 $this->logInAs('admin');
161 $client = $this->getClient();
162
163 $crawler = $client->request('GET', '/config');
164
165 $this->assertEquals(200, $client->getResponse()->getStatusCode());
166
167 $form = $crawler->filter('button[id=change_passwd_save]')->form();
168
169 $data = array(
170 'change_passwd[old_password]' => 'mypassword',
171 'change_passwd[new_password][first]' => 'mypassword',
172 'change_passwd[new_password][second]' => 'mypassword',
173 );
174
175 $client->submit($form, $data);
176
177 $this->assertEquals(302, $client->getResponse()->getStatusCode());
178
179 $crawler = $client->followRedirect();
180
181 $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text')));
182 $this->assertContains('Password updated', $alert[0]);
183 }
96} 184}