|
@@ -45,22 +45,41 @@ class NoPassTest extends FunctionalTest
|
45
|
45
|
|
46
|
46
|
protected function checkUserProhibedActionStatus($match)
|
47
|
47
|
{
|
48
|
|
- foreach (array(
|
|
48
|
+ $this->security_context_test->testUserCantMakeActionStatus(
|
49
|
49
|
SecurityContext::ACTION_ELEMENT_ADD,
|
50
|
|
- SecurityContext::ACTION_ELEMENT_NOTE,
|
51
|
|
- SecurityContext::ACTION_COMMENT_ALERT,
|
52
|
|
- SecurityContext::ACTION_ELEMENT_ALERT,
|
53
|
|
- SecurityContext::ACTION_TAG_ADD,
|
54
|
|
- SecurityContext::ACTION_ELEMENT_TAGS_PROPOSITION,
|
55
|
|
- SecurityContext::ACTION_GROUP_ADD
|
56
|
|
- ) as $action)
|
57
|
|
- {
|
58
|
|
- $this->security_context_test->testUserCantMakeActionStatus(
|
59
|
|
- $action,
|
60
|
|
- SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
61
|
|
- $match
|
62
|
|
- );
|
63
|
|
- }
|
|
50
|
+ SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
|
51
|
+ $match
|
|
52
|
+ );
|
|
53
|
+ $this->security_context_test->testUserCantMakeActionStatus(
|
|
54
|
+ SecurityContext::ACTION_ELEMENT_NOTE,
|
|
55
|
+ SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
|
56
|
+ $match
|
|
57
|
+ );
|
|
58
|
+ $this->security_context_test->testUserCantMakeActionStatus(
|
|
59
|
+ SecurityContext::ACTION_COMMENT_ALERT,
|
|
60
|
+ SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
|
61
|
+ $match
|
|
62
|
+ );
|
|
63
|
+ $this->security_context_test->testUserCantMakeActionStatus(
|
|
64
|
+ SecurityContext::ACTION_ELEMENT_ALERT,
|
|
65
|
+ SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
|
66
|
+ $match
|
|
67
|
+ );
|
|
68
|
+ $this->security_context_test->testUserCantMakeActionStatus(
|
|
69
|
+ SecurityContext::ACTION_TAG_ADD,
|
|
70
|
+ SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
|
71
|
+ $match
|
|
72
|
+ );
|
|
73
|
+ $this->security_context_test->testUserCantMakeActionStatus(
|
|
74
|
+ SecurityContext::ACTION_ELEMENT_TAGS_PROPOSITION,
|
|
75
|
+ SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
|
76
|
+ $match
|
|
77
|
+ );
|
|
78
|
+ $this->security_context_test->testUserCantMakeActionStatus(
|
|
79
|
+ SecurityContext::ACTION_GROUP_ADD,
|
|
80
|
+ SecurityContext::CONDITION_USER_EMAIL_NOT_CONFIRMED,
|
|
81
|
+ $match
|
|
82
|
+ );
|
64
|
83
|
}
|
65
|
84
|
|
66
|
85
|
protected function confirmEmail()
|
|
@@ -82,12 +101,118 @@ class NoPassTest extends FunctionalTest
|
82
|
101
|
|
83
|
102
|
public function testSetPassword()
|
84
|
103
|
{
|
|
104
|
+ $this->init();
|
|
105
|
+ $this->registerUser('trolita@mail.com');
|
|
106
|
+ $this->checkUserPasswordHasNotBeenSet();
|
|
107
|
+ $this->updatePasswordMessageExist();
|
|
108
|
+ $this->updatePassword();
|
|
109
|
+ $this->checkUserPasswordHasBeenSet();
|
|
110
|
+ $this->updatePasswordMessageNotExist();
|
|
111
|
+ }
|
|
112
|
+
|
|
113
|
+ protected function checkUserPasswordHasNotBeenSet()
|
|
114
|
+ {
|
|
115
|
+ $this->assertFalse($this->getUser()->isPasswordSet());
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ protected function updatePasswordMessageExist()
|
|
119
|
+ {
|
|
120
|
+ $this->goToPage($this->generateUrl('home'));
|
|
121
|
+ $this->exist('div.choose_password');
|
|
122
|
+ }
|
|
123
|
+
|
|
124
|
+ protected function updatePassword()
|
|
125
|
+ {
|
|
126
|
+ $this->goToPage($this->generateUrl('my_account'));
|
85
|
127
|
|
|
128
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
129
|
+ 'change_password', array('open' => 'change_password')
|
|
130
|
+ )).'"]');
|
|
131
|
+ $this->exist('form[action="'.$url.'"] input[id="user_password_plain_password_first"]');
|
|
132
|
+ $this->exist('form[action="'.$url.'"] input[id="user_password_plain_password_second"]');
|
|
133
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
134
|
+
|
|
135
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
136
|
+ $form['user_password[plain_password][first]'] = 'trololo';
|
|
137
|
+ $form['user_password[plain_password][second]'] = 'trololo';
|
|
138
|
+ $this->submit($form);
|
|
139
|
+
|
|
140
|
+ $this->isResponseRedirection();
|
|
141
|
+ $this->followRedirection();
|
|
142
|
+ $this->isResponseSuccess();
|
|
143
|
+
|
|
144
|
+ // On se déconnecte
|
|
145
|
+ $this->disconnectUser();
|
|
146
|
+
|
|
147
|
+ // Et on se connecte avec le nouveau mot de passe
|
|
148
|
+ $this->connectUser('trolita@mail.com', 'trololo');
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ protected function checkUserPasswordHasBeenSet()
|
|
152
|
+ {
|
|
153
|
+ $this->assertTrue($this->getUser()->isPasswordSet());
|
|
154
|
+ }
|
|
155
|
+
|
|
156
|
+ protected function updatePasswordMessageNotExist()
|
|
157
|
+ {
|
|
158
|
+ $this->goToPage($this->generateUrl('home'));
|
|
159
|
+ $this->notExist('div.choose_password');
|
86
|
160
|
}
|
87
|
161
|
|
88
|
162
|
public function testSetUsername()
|
89
|
163
|
{
|
|
164
|
+ $this->init();
|
|
165
|
+ $this->registerUser('boulouduf@mail.com');
|
|
166
|
+ $this->userHasNotDefinedUsername();
|
|
167
|
+ $this->updateUserNameLinkExist();
|
|
168
|
+ $this->updateUsername('boulouduf');
|
|
169
|
+ $this->userHasDefinedUsername('boulouduf');
|
|
170
|
+ $this->updateUserNameLinkNotExist();
|
|
171
|
+ }
|
|
172
|
+
|
|
173
|
+ protected function userHasNotDefinedUsername()
|
|
174
|
+ {
|
|
175
|
+ $this->assertTrue($this->getUser()->isUsernameUpdatable());
|
|
176
|
+ }
|
|
177
|
+
|
|
178
|
+ protected function updateUserNameLinkExist()
|
|
179
|
+ {
|
|
180
|
+ $this->goToPage($this->generateUrl('my_account'));
|
|
181
|
+ $this->exist('a.username_update');
|
|
182
|
+ }
|
|
183
|
+
|
|
184
|
+ protected function updateUsername($username)
|
|
185
|
+ {
|
|
186
|
+ $this->goToPage($this->generateUrl('change_username'));
|
|
187
|
+ $extract = $this->crawler->filter('input[name="form[_token]"]')
|
|
188
|
+ ->extract(array('value'));
|
|
189
|
+ $csrf = $extract[0];
|
|
190
|
+ $this->crawler = $this->client->request(
|
|
191
|
+ 'POST',
|
|
192
|
+ $this->generateUrl('change_username'),
|
|
193
|
+ array(
|
|
194
|
+ 'form' => array(
|
|
195
|
+ 'username' => $username,
|
|
196
|
+ '_token' => $csrf
|
|
197
|
+ )
|
|
198
|
+ ),
|
|
199
|
+ array(),
|
|
200
|
+ array()
|
|
201
|
+ );
|
90
|
202
|
|
|
203
|
+ $this->isResponseRedirection();
|
|
204
|
+ }
|
|
205
|
+
|
|
206
|
+ protected function userHasDefinedUsername($username)
|
|
207
|
+ {
|
|
208
|
+ $this->assertEquals($username, $this->getUser()->getUsername());
|
|
209
|
+ $this->assertFalse($this->getUser()->isUsernameUpdatable());
|
|
210
|
+ }
|
|
211
|
+
|
|
212
|
+ protected function updateUserNameLinkNotExist()
|
|
213
|
+ {
|
|
214
|
+ $this->goToPage($this->generateUrl('my_account'));
|
|
215
|
+ $this->notExist('a.username_update');
|
91
|
216
|
}
|
92
|
217
|
|
93
|
218
|
}
|