diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | 89 |
1 files changed, 84 insertions, 5 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 4aceed15..519b4ba2 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | |||
@@ -25,9 +25,9 @@ class ConfigControllerTest extends WallabagTestCase | |||
25 | 25 | ||
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]')); | ||
29 | $this->assertCount(1, $crawler->filter('button[id=config_save]')); | 28 | $this->assertCount(1, $crawler->filter('button[id=config_save]')); |
30 | $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]')); | 29 | $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]')); |
30 | $this->assertCount(1, $crawler->filter('button[id=user_save]')); | ||
31 | } | 31 | } |
32 | 32 | ||
33 | public function testUpdate() | 33 | public function testUpdate() |
@@ -104,7 +104,7 @@ class ConfigControllerTest extends WallabagTestCase | |||
104 | 'change_passwd[new_password][first]' => '', | 104 | 'change_passwd[new_password][first]' => '', |
105 | 'change_passwd[new_password][second]' => '', | 105 | 'change_passwd[new_password][second]' => '', |
106 | ), | 106 | ), |
107 | 'Wrong value for your current password' | 107 | 'Wrong value for your current password', |
108 | ), | 108 | ), |
109 | array( | 109 | array( |
110 | array( | 110 | array( |
@@ -112,7 +112,7 @@ class ConfigControllerTest extends WallabagTestCase | |||
112 | 'change_passwd[new_password][first]' => '', | 112 | 'change_passwd[new_password][first]' => '', |
113 | 'change_passwd[new_password][second]' => '', | 113 | 'change_passwd[new_password][second]' => '', |
114 | ), | 114 | ), |
115 | 'This value should not be blank' | 115 | 'This value should not be blank', |
116 | ), | 116 | ), |
117 | array( | 117 | array( |
118 | array( | 118 | array( |
@@ -120,7 +120,7 @@ class ConfigControllerTest extends WallabagTestCase | |||
120 | 'change_passwd[new_password][first]' => 'hop', | 120 | 'change_passwd[new_password][first]' => 'hop', |
121 | 'change_passwd[new_password][second]' => '', | 121 | 'change_passwd[new_password][second]' => '', |
122 | ), | 122 | ), |
123 | 'The password fields must match' | 123 | 'The password fields must match', |
124 | ), | 124 | ), |
125 | array( | 125 | array( |
126 | array( | 126 | array( |
@@ -128,7 +128,7 @@ class ConfigControllerTest extends WallabagTestCase | |||
128 | 'change_passwd[new_password][first]' => 'hop', | 128 | 'change_passwd[new_password][first]' => 'hop', |
129 | 'change_passwd[new_password][second]' => 'hop', | 129 | 'change_passwd[new_password][second]' => 'hop', |
130 | ), | 130 | ), |
131 | 'Password should by at least 6 chars long' | 131 | 'Password should by at least 6 chars long', |
132 | ), | 132 | ), |
133 | ); | 133 | ); |
134 | } | 134 | } |
@@ -181,4 +181,83 @@ class ConfigControllerTest extends WallabagTestCase | |||
181 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text'))); | 181 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text'))); |
182 | $this->assertContains('Password updated', $alert[0]); | 182 | $this->assertContains('Password updated', $alert[0]); |
183 | } | 183 | } |
184 | |||
185 | public function dataForUserFailed() | ||
186 | { | ||
187 | return array( | ||
188 | array( | ||
189 | array( | ||
190 | 'user[username]' => '', | ||
191 | 'user[name]' => '', | ||
192 | 'user[email]' => '', | ||
193 | ), | ||
194 | 'This value should not be blank.', | ||
195 | ), | ||
196 | array( | ||
197 | array( | ||
198 | 'user[username]' => 'ad', | ||
199 | 'user[name]' => '', | ||
200 | 'user[email]' => '', | ||
201 | ), | ||
202 | 'This value is too short.', | ||
203 | ), | ||
204 | array( | ||
205 | array( | ||
206 | 'user[username]' => 'admin', | ||
207 | 'user[name]' => '', | ||
208 | 'user[email]' => 'test', | ||
209 | ), | ||
210 | 'This value is not a valid email address.', | ||
211 | ), | ||
212 | ); | ||
213 | } | ||
214 | |||
215 | /** | ||
216 | * @dataProvider dataForUserFailed | ||
217 | */ | ||
218 | public function testUserFailed($data, $expectedMessage) | ||
219 | { | ||
220 | $this->logInAs('admin'); | ||
221 | $client = $this->getClient(); | ||
222 | |||
223 | $crawler = $client->request('GET', '/config'); | ||
224 | |||
225 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
226 | |||
227 | $form = $crawler->filter('button[id=user_save]')->form(); | ||
228 | |||
229 | $crawler = $client->submit($form, $data); | ||
230 | |||
231 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
232 | |||
233 | $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text'))); | ||
234 | $this->assertContains($expectedMessage, $alert[0]); | ||
235 | } | ||
236 | |||
237 | public function testUserUpdate() | ||
238 | { | ||
239 | $this->logInAs('admin'); | ||
240 | $client = $this->getClient(); | ||
241 | |||
242 | $crawler = $client->request('GET', '/config'); | ||
243 | |||
244 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
245 | |||
246 | $form = $crawler->filter('button[id=user_save]')->form(); | ||
247 | |||
248 | $data = array( | ||
249 | 'user[username]' => 'admin', | ||
250 | 'user[name]' => 'new name', | ||
251 | 'user[email]' => 'admin@wallabag.io', | ||
252 | ); | ||
253 | |||
254 | $client->submit($form, $data); | ||
255 | |||
256 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
257 | |||
258 | $crawler = $client->followRedirect(); | ||
259 | |||
260 | $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text'))); | ||
261 | $this->assertContains('Information updated', $alert[0]); | ||
262 | } | ||
184 | } | 263 | } |