|
@@ -162,4 +162,81 @@ class IndexControllerTest extends FunctionalTest
|
162
|
162
|
);
|
163
|
163
|
}
|
164
|
164
|
|
|
165
|
+ /**
|
|
166
|
+ * Test du changement de mot de passe
|
|
167
|
+ */
|
|
168
|
+ public function testPasswordLost()
|
|
169
|
+ {
|
|
170
|
+ $this->client = self::createClient();
|
|
171
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
|
|
172
|
+
|
|
173
|
+ $bux = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')->findOneByUsername('bux');
|
|
174
|
+
|
|
175
|
+ // On peux voir le lien vers al page de demande de mot de passe
|
|
176
|
+ $this->exist('a[href="'.($url = $this->generateUrl('fos_user_resetting_request')).'"]');
|
|
177
|
+ $link = $this->selectLink('a[href="'.$url.'"]');
|
|
178
|
+ $this->clickOnLink($link);
|
|
179
|
+
|
|
180
|
+ $this->isResponseSuccess();
|
|
181
|
+
|
|
182
|
+ // On trouve le formulaire
|
|
183
|
+ $this->exist('form[action="'.($url = $this->generateUrl('fos_user_resetting_send_email')).'"]');
|
|
184
|
+ $this->exist('form[action="'.$url.'"] input[id="username"]');
|
|
185
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
186
|
+
|
|
187
|
+ // On selectionne le form
|
|
188
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
189
|
+ $form['username'] = 'bux';
|
|
190
|
+ $this->submit($form);
|
|
191
|
+
|
|
192
|
+ $mc = $this->getMailerMessageDataCollector();
|
|
193
|
+ $this->assertEquals(1, $mc->getMessageCount());
|
|
194
|
+
|
|
195
|
+ $mails = $mc->getMessages();
|
|
196
|
+ $mail = $mails[0];
|
|
197
|
+
|
|
198
|
+ // $mail = new Swift_Message();
|
|
199
|
+
|
|
200
|
+ $this->assertTrue(!is_null(strpos($mail->getBody(), ($url = $this->generateUrl(
|
|
201
|
+ 'fos_user_resetting_reset',
|
|
202
|
+ array('token' => $bux->getConfirmationToken()),
|
|
203
|
+ true
|
|
204
|
+ )))));
|
|
205
|
+
|
|
206
|
+ $keys = array_keys($mail->getTo());
|
|
207
|
+ $this->assertEquals($bux->getEmail(), $keys[0]);
|
|
208
|
+
|
|
209
|
+ $this->isResponseRedirection();
|
|
210
|
+ $this->followRedirection();
|
|
211
|
+ $this->isResponseSuccess();
|
|
212
|
+ $this->exist('html:contains("'.$bux->getEmail().'")');
|
|
213
|
+
|
|
214
|
+ // On se rend sur le lien envoyé dans le mail
|
|
215
|
+ $this->crawler = $this->client->request('GET', $url);
|
|
216
|
+
|
|
217
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
218
|
+ 'fos_user_resetting_reset',
|
|
219
|
+ array('token' => $bux->getConfirmationToken())
|
|
220
|
+ )).'"]');
|
|
221
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_resetting_form_new_first"]');
|
|
222
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_resetting_form_new_second"]');
|
|
223
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
224
|
+
|
|
225
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
226
|
+ $form['fos_user_resetting_form[new][first]'] = 'trololo';
|
|
227
|
+ $form['fos_user_resetting_form[new][second]'] = 'trololo';
|
|
228
|
+ $this->submit($form);
|
|
229
|
+
|
|
230
|
+ $this->isResponseRedirection();
|
|
231
|
+ $this->followRedirection();
|
|
232
|
+ $this->isResponseSuccess();
|
|
233
|
+ $this->outputDebug();
|
|
234
|
+ // A ce stade on a été connecté
|
|
235
|
+ $this->assertEquals('bux', $this->getUser()->getUsername());
|
|
236
|
+
|
|
237
|
+ // On se déconnecte pour aller tester ce nouveau mot de passe
|
|
238
|
+ $this->disconnectUser();
|
|
239
|
+ $this->connectUser('bux', 'trololo');
|
|
240
|
+ }
|
|
241
|
+
|
165
|
242
|
}
|