aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-02-22 09:30:25 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-02-22 09:30:25 +0100
commite4977b8a866f84f65f08c55c050a62f40170fdbf (patch)
treef42886d6691d18ad8860b3ee2565f857204c7857 /src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
parentc0d9eba07f40a52bdfcfca3e7a926163b17d83ab (diff)
downloadwallabag-e4977b8a866f84f65f08c55c050a62f40170fdbf.tar.gz
wallabag-e4977b8a866f84f65f08c55c050a62f40170fdbf.tar.zst
wallabag-e4977b8a866f84f65f08c55c050a62f40170fdbf.zip
Adding new user
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php89
1 files changed, 88 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
index 519b4ba2..9b1a0986 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -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',
132 ), 132 ),
133 ); 133 );
134 } 134 }
@@ -260,4 +260,91 @@ class ConfigControllerTest extends WallabagTestCase
260 $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text'))); 260 $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text')));
261 $this->assertContains('Information updated', $alert[0]); 261 $this->assertContains('Information updated', $alert[0]);
262 } 262 }
263
264 public function dataForNewUserFailed()
265 {
266 return array(
267 array(
268 array(
269 'new_user[username]' => '',
270 'new_user[password]' => '',
271 'new_user[email]' => '',
272 ),
273 'This value should not be blank.',
274 ),
275 array(
276 array(
277 'new_user[username]' => 'ad',
278 'new_user[password]' => '',
279 'new_user[email]' => '',
280 ),
281 'This value is too short.',
282 ),
283 array(
284 array(
285 'new_user[username]' => 'wallace',
286 'new_user[password]' => '',
287 'new_user[email]' => 'test',
288 ),
289 'This value is not a valid email address.',
290 ),
291 array(
292 array(
293 'new_user[username]' => 'wallace',
294 'new_user[password]' => 'admin',
295 'new_user[email]' => 'wallace@wallace.me',
296 ),
297 'Password should by at least',
298 ),
299 );
300 }
301
302 /**
303 * @dataProvider dataForNewUserFailed
304 */
305 public function testNewUserFailed($data, $expectedMessage)
306 {
307 $this->logInAs('admin');
308 $client = $this->getClient();
309
310 $crawler = $client->request('GET', '/config');
311
312 $this->assertEquals(200, $client->getResponse()->getStatusCode());
313
314 $form = $crawler->filter('button[id=new_user_save]')->form();
315
316 $crawler = $client->submit($form, $data);
317
318 $this->assertEquals(200, $client->getResponse()->getStatusCode());
319
320 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
321 $this->assertContains($expectedMessage, $alert[0]);
322 }
323
324 public function testNewUserCreated()
325 {
326 $this->logInAs('admin');
327 $client = $this->getClient();
328
329 $crawler = $client->request('GET', '/config');
330
331 $this->assertEquals(200, $client->getResponse()->getStatusCode());
332
333 $form = $crawler->filter('button[id=new_user_save]')->form();
334
335 $data = array(
336 'new_user[username]' => 'wallace',
337 'new_user[password]' => 'wallace1',
338 'new_user[email]' => 'wallace@wallace.me',
339 );
340
341 $client->submit($form, $data);
342
343 $this->assertEquals(302, $client->getResponse()->getStatusCode());
344
345 $crawler = $client->followRedirect();
346
347 $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text')));
348 $this->assertContains('User "wallace" added', $alert[0]);
349 }
263} 350}