diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-09-29 17:05:17 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-10-03 13:30:43 +0200 |
commit | 359b3f43cc42aa593cdba7dc8e1d6fa121cc3f6a (patch) | |
tree | df971ec01e9f8add70a403a65fdd2e4114373f71 /src/Wallabag/CoreBundle/Tests | |
parent | 772732531ea1d0f9831cc5f29e11b6b11fd088f3 (diff) | |
download | wallabag-359b3f43cc42aa593cdba7dc8e1d6fa121cc3f6a.tar.gz wallabag-359b3f43cc42aa593cdba7dc8e1d6fa121cc3f6a.tar.zst wallabag-359b3f43cc42aa593cdba7dc8e1d6fa121cc3f6a.zip |
* rename AuthenticationListener
* add tests
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php index 759ef01b..78b4952e 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/SecurityControllerTest.php | |||
@@ -8,6 +8,99 @@ use Wallabag\CoreBundle\Tests\WallabagCoreTestCase; | |||
8 | 8 | ||
9 | class SecurityControllerTest extends WallabagCoreTestCase | 9 | class SecurityControllerTest extends WallabagCoreTestCase |
10 | { | 10 | { |
11 | public function testRegister() | ||
12 | { | ||
13 | $client = $this->getClient(); | ||
14 | |||
15 | $crawler = $client->request('GET', '/register/'); | ||
16 | |||
17 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
18 | $this->assertContains('Register', $client->getResponse()->getContent()); | ||
19 | } | ||
20 | |||
21 | public function dataForCreateAccountFailed() | ||
22 | { | ||
23 | return array( | ||
24 | array( | ||
25 | array( | ||
26 | 'fos_user_registration_form[email]' => '', | ||
27 | 'fos_user_registration_form[username]' => 'newuser', | ||
28 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword', | ||
29 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword', | ||
30 | ), | ||
31 | 'Please enter an email', | ||
32 | ), | ||
33 | array( | ||
34 | array( | ||
35 | 'fos_user_registration_form[email]' => 'newuser@wallabag.org', | ||
36 | 'fos_user_registration_form[username]' => 'admin', | ||
37 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword', | ||
38 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword', | ||
39 | ), | ||
40 | 'The username is already used', | ||
41 | ), | ||
42 | array( | ||
43 | array( | ||
44 | 'fos_user_registration_form[email]' => 'newuser@wallabag.org', | ||
45 | 'fos_user_registration_form[username]' => 'newuser', | ||
46 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword1', | ||
47 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword2', | ||
48 | ), | ||
49 | 'The entered passwords don't match', | ||
50 | ), | ||
51 | ); | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * @dataProvider dataForCreateAccountFailed | ||
56 | */ | ||
57 | public function testCreateAccountFailed($data, $expectedMessage) | ||
58 | { | ||
59 | $client = $this->getClient(); | ||
60 | |||
61 | $crawler = $client->request('GET', '/register/'); | ||
62 | |||
63 | $form = $crawler->filter('input[type=submit]')->form(); | ||
64 | |||
65 | $client->submit($form, $data); | ||
66 | |||
67 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
68 | $this->assertContains($expectedMessage, $client->getResponse()->getContent()); | ||
69 | } | ||
70 | |||
71 | public function dataForCreateAccountSuccess() | ||
72 | { | ||
73 | return array( | ||
74 | array( | ||
75 | array( | ||
76 | 'fos_user_registration_form[email]' => 'newuser@wallabag.org', | ||
77 | 'fos_user_registration_form[username]' => 'newuser', | ||
78 | 'fos_user_registration_form[plainPassword][first]' => 'mypassword', | ||
79 | 'fos_user_registration_form[plainPassword][second]' => 'mypassword', | ||
80 | ), | ||
81 | ) | ||
82 | ); | ||
83 | } | ||
84 | |||
85 | /** | ||
86 | * @dataProvider dataForCreateAccountSuccess | ||
87 | */ | ||
88 | public function testCreateAccountSuccess($data) | ||
89 | { | ||
90 | $client = $this->getClient(); | ||
91 | |||
92 | $crawler = $client->request('GET', '/register/'); | ||
93 | |||
94 | $form = $crawler->filter('input[type=submit]')->form(); | ||
95 | |||
96 | $client->submit($form, $data); | ||
97 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | ||
98 | |||
99 | $crawler = $client->followRedirect(); | ||
100 | |||
101 | $this->assertContains('The user has been created successfully', $client->getResponse()->getContent()); | ||
102 | } | ||
103 | |||
11 | public function testLogin() | 104 | public function testLogin() |
12 | { | 105 | { |
13 | $client = $this->getClient(); | 106 | $client = $this->getClient(); |