|
@@ -8,349 +8,349 @@ use Muzich\CoreBundle\Entity\RegistrationToken;
|
8
|
8
|
class UserControllerTest extends FunctionalTest
|
9
|
9
|
{
|
10
|
10
|
|
11
|
|
-// public function testTagsFavoritesSuccess()
|
12
|
|
-// {
|
13
|
|
-// /**
|
14
|
|
-// * Inscription d'un utilisateur
|
15
|
|
-// */
|
16
|
|
-// $this->client = self::createClient();
|
17
|
|
-//
|
18
|
|
-// $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
19
|
|
-// $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
20
|
|
-//
|
21
|
|
-// $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
|
22
|
|
-// $this->isResponseSuccess();
|
23
|
|
-//
|
24
|
|
-// // On a besoin d'un token pour le moment
|
25
|
|
-// $token = new RegistrationToken();
|
26
|
|
-// $token->setToken('hekt78yl789dzafdfz');
|
27
|
|
-// $em = $this->getDoctrine()->getEntityManager();
|
28
|
|
-// $em->persist($token);
|
29
|
|
-// $em->flush();
|
30
|
|
-//
|
31
|
|
-// $this->procedure_registration_success(
|
32
|
|
-// 'raoulc',
|
33
|
|
-// 'raoulc.def4v65sds@gmail.com',
|
34
|
|
-// 'toor',
|
35
|
|
-// 'toor',
|
36
|
|
-// 'hekt78yl789dzafdfz'
|
37
|
|
-// );
|
38
|
|
-//
|
39
|
|
-// // Il ne doit y avoir aucun enregistrements de tags favoris
|
40
|
|
-// $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
41
|
|
-// ->findBy(array(
|
42
|
|
-// 'user' => $this->getUser()->getId()
|
43
|
|
-// ))
|
44
|
|
-// ;
|
45
|
|
-//
|
46
|
|
-// $this->assertEquals(0, count($Favorites));
|
47
|
|
-//
|
48
|
|
-// // On a attérit sur la page de présentation et de sleection des tags favoris
|
49
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl('update_tag_favorites')).'"]');
|
50
|
|
-//
|
51
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
52
|
|
-// $form['tag_favorites_form[tags]'] = json_encode(array($hardtek_id,$tribe_id));
|
53
|
|
-// $this->submit($form);
|
54
|
|
-//
|
55
|
|
-// $this->isResponseRedirection();
|
56
|
|
-// $this->followRedirection();
|
57
|
|
-// $this->isResponseSuccess();
|
58
|
|
-//
|
59
|
|
-// // Désormais il y a deux tags favoris pour cet utilisateur
|
60
|
|
-// $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
61
|
|
-// ->findBy(array(
|
62
|
|
-// 'user' => $this->getUser()->getId()
|
63
|
|
-// ))
|
64
|
|
-// ;
|
65
|
|
-// $this->assertEquals(2, count($Favorites));
|
66
|
|
-//
|
67
|
|
-// $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
68
|
|
-// ->findBy(array(
|
69
|
|
-// 'user' => $this->getUser()->getId(),
|
70
|
|
-// 'tag' => $hardtek_id
|
71
|
|
-// ))
|
72
|
|
-// ;
|
73
|
|
-// $this->assertEquals(1, count($Favorites));
|
74
|
|
-//
|
75
|
|
-// $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
76
|
|
-// ->findBy(array(
|
77
|
|
-// 'user' => $this->getUser()->getId(),
|
78
|
|
-// 'tag' => $tribe_id
|
79
|
|
-// ))
|
80
|
|
-// ;
|
81
|
|
-// $this->assertEquals(1, count($Favorites));
|
82
|
|
-// }
|
83
|
|
-//
|
84
|
|
-// /**
|
85
|
|
-// * Test du changement de mot de passe par le baisis de la page 'Mon compte'
|
86
|
|
-// */
|
87
|
|
-// public function testChangePassword()
|
88
|
|
-// {
|
89
|
|
-// $this->client = self::createClient();
|
90
|
|
-// $this->connectUser('bux', 'toor');
|
91
|
|
-//
|
92
|
|
-// // Ouverture de la page Mon compte
|
93
|
|
-// $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
94
|
|
-//
|
95
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl(
|
96
|
|
-// 'change_password'
|
97
|
|
-// )).'"]');
|
98
|
|
-// $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_current"]');
|
99
|
|
-// $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_new_first"]');
|
100
|
|
-// $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_new_second"]');
|
101
|
|
-// $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
102
|
|
-//
|
103
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
104
|
|
-// $form['fos_user_change_password_form[current]'] = 'toor';
|
105
|
|
-// $form['fos_user_change_password_form[new][first]'] = 'trololo';
|
106
|
|
-// $form['fos_user_change_password_form[new][second]'] = 'trololo';
|
107
|
|
-// $this->submit($form);
|
108
|
|
-//
|
109
|
|
-// $this->isResponseRedirection();
|
110
|
|
-// $this->followRedirection();
|
111
|
|
-// $this->isResponseSuccess();
|
112
|
|
-//
|
113
|
|
-// // On se déconnecte
|
114
|
|
-// $this->disconnectUser();
|
115
|
|
-//
|
116
|
|
-// // Et on se connecte avec le nouveau mot de passe
|
117
|
|
-// $this->connectUser('bux', 'trololo');
|
118
|
|
-// }
|
119
|
|
-//
|
120
|
|
-// /**
|
121
|
|
-// * Test du formulaire de mise a jour des tags par le baisis de la page 'Mon compte'
|
122
|
|
-// */
|
123
|
|
-// public function testUpdateFavoriteTags()
|
124
|
|
-// {
|
125
|
|
-// $this->client = self::createClient();
|
126
|
|
-// $this->connectUser('bob', 'toor');
|
127
|
|
-//
|
128
|
|
-// // Ouverture de la page Mon compte
|
129
|
|
-// $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
130
|
|
-//
|
131
|
|
-// $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
132
|
|
-// $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
133
|
|
-//
|
134
|
|
-// // Bob n'a aucun tag préféré
|
135
|
|
-// $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
136
|
|
-// ->findBy(array('user' => $this->getUser()->getId()))
|
137
|
|
-// ;
|
138
|
|
-//
|
139
|
|
-// $this->assertEquals(0, count($prefereds));
|
140
|
|
-//
|
141
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl(
|
142
|
|
-// 'update_tag_favorites', array('redirect' => 'account')
|
143
|
|
-// )).'"]');
|
144
|
|
-// $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
145
|
|
-//
|
146
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
147
|
|
-// $form['tag_favorites_form[tags]'] = json_encode(array($hardtek_id,$tribe_id));
|
148
|
|
-// $this->submit($form);
|
149
|
|
-//
|
150
|
|
-// $this->isResponseRedirection();
|
151
|
|
-// $this->followRedirection();
|
152
|
|
-// $this->isResponseSuccess();
|
153
|
|
-//
|
154
|
|
-// // On a été redirigé sur la page Mon compte
|
155
|
|
-// $this->exist('form[action="'.$url.'"]');
|
156
|
|
-//
|
157
|
|
-// // On vérifie la présence en base des enregistrements
|
158
|
|
-// $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
159
|
|
-// ->findBy(array('user' => $this->getUser()->getId()))
|
160
|
|
-// ;
|
161
|
|
-//
|
162
|
|
-// $this->assertEquals(2, count($prefereds));
|
163
|
|
-//
|
164
|
|
-// // On vérifie la présence en base des enregistrements
|
165
|
|
-// $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
166
|
|
-// ->findBy(array(
|
167
|
|
-// 'user' => $this->getUser()->getId(),
|
168
|
|
-// 'tag' => $hardtek_id
|
169
|
|
-// ))
|
170
|
|
-// ;
|
171
|
|
-//
|
172
|
|
-// $this->assertEquals(1, count($prefereds));
|
173
|
|
-//
|
174
|
|
-// // On vérifie la présence en base des enregistrements
|
175
|
|
-// $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
176
|
|
-// ->findBy(array(
|
177
|
|
-// 'user' => $this->getUser()->getId(),
|
178
|
|
-// 'tag' => $tribe_id
|
179
|
|
-// ))
|
180
|
|
-// ;
|
181
|
|
-//
|
182
|
|
-// $this->assertEquals(1, count($prefereds));
|
183
|
|
-// }
|
184
|
|
-//
|
185
|
|
-// /**
|
186
|
|
-// * Test de al procédure de changement d'email.
|
187
|
|
-// */
|
188
|
|
-// public function testChangeEmail()
|
189
|
|
-// {
|
190
|
|
-// $this->client = self::createClient();
|
191
|
|
-// $this->connectUser('bob', 'toor');
|
192
|
|
-// $bob = $this->findUserByUsername('bob');
|
193
|
|
-//
|
194
|
|
-// // Ouverture de la page Mon compte
|
195
|
|
-// $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
196
|
|
-//
|
197
|
|
-// // Le mail en cours n'est pas celui que nous voulons mettre
|
198
|
|
-// $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
199
|
|
-// // Nous n'avons pas encore demandé de nouveau mail
|
200
|
|
-// $this->assertTrue($bob->getEmailRequested() == null);
|
201
|
|
-// $this->assertTrue($bob->getEmailRequestedDatetime() == null);
|
202
|
|
-//
|
203
|
|
-// // On fait un premier essaie avec une email mal formulé
|
204
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl(
|
205
|
|
-// 'change_email_request'
|
206
|
|
-// )).'"]');
|
207
|
|
-// $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
208
|
|
-//
|
209
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
210
|
|
-// $form['form[email]'] = 'trololololooo@trolo';
|
211
|
|
-// $this->submit($form);
|
212
|
|
-//
|
213
|
|
-// // Il n'y as pas de redirection
|
214
|
|
-// $this->isResponseSuccess();
|
215
|
|
-//
|
216
|
|
-// $bob = $this->findUserByUsername('bob');
|
217
|
|
-// // Les champs n'ont pas bougés
|
218
|
|
-// $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
219
|
|
-// // Nous n'avons pas encore demandé de nouveau mail
|
220
|
|
-// $this->assertTrue($bob->getEmailRequested() == null);
|
221
|
|
-// $this->assertTrue($bob->getEmailRequestedDatetime() == null);
|
222
|
|
-//
|
223
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl(
|
224
|
|
-// 'change_email_request'
|
225
|
|
-// )).'"]');
|
226
|
|
-// $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
227
|
|
-//
|
228
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
229
|
|
-// $form['form[email]'] = 'trololololooo@trolo.com';
|
230
|
|
-// $this->submit($form);
|
231
|
|
-//
|
232
|
|
-// // Ce coup-ci c'est bien une redirection
|
233
|
|
-// $this->isResponseRedirection();
|
234
|
|
-//
|
235
|
|
-// // Un mail a été envoyé
|
236
|
|
-// $mc = $this->getMailerMessageDataCollector();
|
237
|
|
-// $this->assertEquals(1, $mc->getMessageCount());
|
238
|
|
-//
|
239
|
|
-// $mails = $mc->getMessages();
|
240
|
|
-// $mail = $mails[0];
|
241
|
|
-//
|
242
|
|
-// // Les champs ont bougés
|
243
|
|
-// $bob = $this->findUserByUsername('bob');
|
244
|
|
-// $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
245
|
|
-// $this->assertFalse($bob->getEmailRequested() == null);
|
246
|
|
-// $this->assertTrue($bob->getEmailRequested() == 'trololololooo@trolo.com');
|
247
|
|
-// $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
248
|
|
-//
|
249
|
|
-// $this->followRedirection();
|
250
|
|
-// $this->isResponseSuccess();
|
251
|
|
-//
|
252
|
|
-// // On ouvre un lien erroné
|
253
|
|
-// $badurl = $this->generateUrl(
|
254
|
|
-// 'change_email_confirm',
|
255
|
|
-// array('token' => $this->getUser()->getConfirmationToken()),
|
256
|
|
-// true
|
257
|
|
-// );
|
258
|
|
-// $this->crawler = $this->client->request('GET', $badurl);
|
259
|
|
-// $this->isResponseRedirection();
|
260
|
|
-// $this->followRedirection();
|
261
|
|
-// $this->isResponseSuccess();
|
262
|
|
-// $this->exist('div.error');
|
263
|
|
-//
|
264
|
|
-// // Et les champs ont pas bougés
|
265
|
|
-// $bob = $this->findUserByUsername('bob');
|
266
|
|
-// $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
267
|
|
-// $this->assertFalse($bob->getEmailRequested() == null);
|
268
|
|
-// $this->assertTrue($bob->getEmailRequested() == 'trololololooo@trolo.com');
|
269
|
|
-// $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
270
|
|
-//
|
271
|
|
-// $this->assertTrue(!is_null(strpos($mail->getBody(), ($url = $this->generateUrl(
|
272
|
|
-// 'change_email_confirm',
|
273
|
|
-// array('token' => $token = hash('sha256', $bob->getConfirmationToken().'trololololooo@trolo.com')),
|
274
|
|
-// true
|
275
|
|
-// )))));
|
276
|
|
-//
|
277
|
|
-// // On ouvre le bon lien
|
278
|
|
-// $this->crawler = $this->client->request('GET', $url);
|
279
|
|
-//
|
280
|
|
-// // C'est un succés
|
281
|
|
-// $this->isResponseRedirection();
|
282
|
|
-// $this->followRedirection();
|
283
|
|
-// $this->isResponseSuccess();
|
284
|
|
-//
|
285
|
|
-// $this->notExist('div.error');
|
286
|
|
-//
|
287
|
|
-// // Et les champs ont bougés
|
288
|
|
-// $bob = $this->findUserByUsername('bob');
|
289
|
|
-// $this->assertTrue($bob->getEmail() == 'trololololooo@trolo.com');
|
290
|
|
-// $this->assertTrue($bob->getEmailRequested() == null);
|
291
|
|
-// $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
292
|
|
-//
|
293
|
|
-// // Par contre si on refait une demande maintenant ca échoue (délais entre demandes)
|
294
|
|
-// $this->exist('form[action="'.($url = $this->generateUrl(
|
295
|
|
-// 'change_email_request'
|
296
|
|
-// )).'"]');
|
297
|
|
-// $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
298
|
|
-//
|
299
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
300
|
|
-// $form['form[email]'] = 'trololololooo222@trolo.com';
|
301
|
|
-// $this->submit($form);
|
302
|
|
-//
|
303
|
|
-// // Il n'y as pas de redirection
|
304
|
|
-// $this->isResponseRedirection();
|
305
|
|
-// $this->followRedirection();
|
306
|
|
-// $this->isResponseSuccess();
|
307
|
|
-// $this->exist('div.error');
|
308
|
|
-//
|
309
|
|
-// // Et les champs ont bougés
|
310
|
|
-// $bob = $this->findUserByUsername('bob');
|
311
|
|
-// $this->assertTrue($bob->getEmail() == 'trololololooo@trolo.com');
|
312
|
|
-// $this->assertTrue($bob->getEmailRequested() == null);
|
313
|
|
-// $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
314
|
|
-//
|
315
|
|
-// // Si par contre on manipule le dateTime on pourra
|
316
|
|
-// $bob = $this->findUserByUsername('bob');
|
317
|
|
-// $bob->setEmailRequestedDatetime(
|
318
|
|
-// $this->getUser()->getEmailRequestedDatetime()
|
319
|
|
-// - $this->getContainer()->getParameter('changeemail_security_delay')
|
320
|
|
-// );
|
321
|
|
-//
|
322
|
|
-// $this->getDoctrine()->getEntityManager()->flush();
|
323
|
|
-//
|
324
|
|
-// $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
325
|
|
-// $form['form[email]'] = 'trololololooo222@trolo.com';
|
326
|
|
-// $this->submit($form);
|
327
|
|
-//
|
328
|
|
-// // Ce coup-ci c'est bien une redirection
|
329
|
|
-// $this->isResponseRedirection();
|
330
|
|
-//
|
331
|
|
-// // Un mail a été envoyé
|
332
|
|
-// $mc = $this->getMailerMessageDataCollector();
|
333
|
|
-// $this->assertEquals(1, $mc->getMessageCount());
|
334
|
|
-//
|
335
|
|
-// $mails = $mc->getMessages();
|
336
|
|
-// $mail = $mails[0];
|
337
|
|
-//
|
338
|
|
-// $this->assertTrue(!is_null(strpos($mail->getBody(), ($url = $this->generateUrl(
|
339
|
|
-// 'change_email_confirm',
|
340
|
|
-// array('token' => hash('sha256', $this->getUser()->getConfirmationToken().'trololololooo222@trolo.com')),
|
341
|
|
-// true
|
342
|
|
-// )))));
|
343
|
|
-//
|
344
|
|
-// // Les champs ont bougés
|
345
|
|
-// $bob = $this->findUserByUsername('bob');
|
346
|
|
-// $this->assertFalse($bob->getEmail() == 'trololololooo222@trolo.com');
|
347
|
|
-// $this->assertFalse($bob->getEmailRequested() == null);
|
348
|
|
-// $this->assertTrue($bob->getEmailRequested() == 'trololololooo222@trolo.com');
|
349
|
|
-// $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
350
|
|
-//
|
351
|
|
-// $this->followRedirection();
|
352
|
|
-// $this->isResponseSuccess();
|
353
|
|
-// }
|
|
11
|
+ public function testTagsFavoritesSuccess()
|
|
12
|
+ {
|
|
13
|
+ /**
|
|
14
|
+ * Inscription d'un utilisateur
|
|
15
|
+ */
|
|
16
|
+ $this->client = self::createClient();
|
|
17
|
+
|
|
18
|
+ $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
19
|
+ $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
20
|
+
|
|
21
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
|
|
22
|
+ $this->isResponseSuccess();
|
|
23
|
+
|
|
24
|
+ // On a besoin d'un token pour le moment
|
|
25
|
+ $token = new RegistrationToken();
|
|
26
|
+ $token->setToken('hekt78yl789dzafdfz');
|
|
27
|
+ $em = $this->getDoctrine()->getEntityManager();
|
|
28
|
+ $em->persist($token);
|
|
29
|
+ $em->flush();
|
|
30
|
+
|
|
31
|
+ $this->procedure_registration_success(
|
|
32
|
+ 'raoulc',
|
|
33
|
+ 'raoulc.def4v65sds@gmail.com',
|
|
34
|
+ 'toor',
|
|
35
|
+ 'toor',
|
|
36
|
+ 'hekt78yl789dzafdfz'
|
|
37
|
+ );
|
|
38
|
+
|
|
39
|
+ // Il ne doit y avoir aucun enregistrements de tags favoris
|
|
40
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
41
|
+ ->findBy(array(
|
|
42
|
+ 'user' => $this->getUser()->getId()
|
|
43
|
+ ))
|
|
44
|
+ ;
|
|
45
|
+
|
|
46
|
+ $this->assertEquals(0, count($Favorites));
|
|
47
|
+
|
|
48
|
+ // On a attérit sur la page de présentation et de sleection des tags favoris
|
|
49
|
+ $this->exist('form[action="'.($url = $this->generateUrl('update_tag_favorites')).'"]');
|
|
50
|
+
|
|
51
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
52
|
+ $form['tag_favorites_form[tags]'] = json_encode(array($hardtek_id,$tribe_id));
|
|
53
|
+ $this->submit($form);
|
|
54
|
+
|
|
55
|
+ $this->isResponseRedirection();
|
|
56
|
+ $this->followRedirection();
|
|
57
|
+ $this->isResponseSuccess();
|
|
58
|
+
|
|
59
|
+ // Désormais il y a deux tags favoris pour cet utilisateur
|
|
60
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
61
|
+ ->findBy(array(
|
|
62
|
+ 'user' => $this->getUser()->getId()
|
|
63
|
+ ))
|
|
64
|
+ ;
|
|
65
|
+ $this->assertEquals(2, count($Favorites));
|
|
66
|
+
|
|
67
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
68
|
+ ->findBy(array(
|
|
69
|
+ 'user' => $this->getUser()->getId(),
|
|
70
|
+ 'tag' => $hardtek_id
|
|
71
|
+ ))
|
|
72
|
+ ;
|
|
73
|
+ $this->assertEquals(1, count($Favorites));
|
|
74
|
+
|
|
75
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
76
|
+ ->findBy(array(
|
|
77
|
+ 'user' => $this->getUser()->getId(),
|
|
78
|
+ 'tag' => $tribe_id
|
|
79
|
+ ))
|
|
80
|
+ ;
|
|
81
|
+ $this->assertEquals(1, count($Favorites));
|
|
82
|
+ }
|
|
83
|
+
|
|
84
|
+ /**
|
|
85
|
+ * Test du changement de mot de passe par le baisis de la page 'Mon compte'
|
|
86
|
+ */
|
|
87
|
+ public function testChangePassword()
|
|
88
|
+ {
|
|
89
|
+ $this->client = self::createClient();
|
|
90
|
+ $this->connectUser('bux', 'toor');
|
|
91
|
+
|
|
92
|
+ // Ouverture de la page Mon compte
|
|
93
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
|
94
|
+
|
|
95
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
96
|
+ 'change_password'
|
|
97
|
+ )).'"]');
|
|
98
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_current"]');
|
|
99
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_new_first"]');
|
|
100
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_new_second"]');
|
|
101
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
102
|
+
|
|
103
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
104
|
+ $form['fos_user_change_password_form[current]'] = 'toor';
|
|
105
|
+ $form['fos_user_change_password_form[new][first]'] = 'trololo';
|
|
106
|
+ $form['fos_user_change_password_form[new][second]'] = 'trololo';
|
|
107
|
+ $this->submit($form);
|
|
108
|
+
|
|
109
|
+ $this->isResponseRedirection();
|
|
110
|
+ $this->followRedirection();
|
|
111
|
+ $this->isResponseSuccess();
|
|
112
|
+
|
|
113
|
+ // On se déconnecte
|
|
114
|
+ $this->disconnectUser();
|
|
115
|
+
|
|
116
|
+ // Et on se connecte avec le nouveau mot de passe
|
|
117
|
+ $this->connectUser('bux', 'trololo');
|
|
118
|
+ }
|
|
119
|
+
|
|
120
|
+ /**
|
|
121
|
+ * Test du formulaire de mise a jour des tags par le baisis de la page 'Mon compte'
|
|
122
|
+ */
|
|
123
|
+ public function testUpdateFavoriteTags()
|
|
124
|
+ {
|
|
125
|
+ $this->client = self::createClient();
|
|
126
|
+ $this->connectUser('bob', 'toor');
|
|
127
|
+
|
|
128
|
+ // Ouverture de la page Mon compte
|
|
129
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
|
130
|
+
|
|
131
|
+ $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
132
|
+ $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
133
|
+
|
|
134
|
+ // Bob n'a aucun tag préféré
|
|
135
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
136
|
+ ->findBy(array('user' => $this->getUser()->getId()))
|
|
137
|
+ ;
|
|
138
|
+
|
|
139
|
+ $this->assertEquals(0, count($prefereds));
|
|
140
|
+
|
|
141
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
142
|
+ 'update_tag_favorites', array('redirect' => 'account')
|
|
143
|
+ )).'"]');
|
|
144
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
145
|
+
|
|
146
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
147
|
+ $form['tag_favorites_form[tags]'] = json_encode(array($hardtek_id,$tribe_id));
|
|
148
|
+ $this->submit($form);
|
|
149
|
+
|
|
150
|
+ $this->isResponseRedirection();
|
|
151
|
+ $this->followRedirection();
|
|
152
|
+ $this->isResponseSuccess();
|
|
153
|
+
|
|
154
|
+ // On a été redirigé sur la page Mon compte
|
|
155
|
+ $this->exist('form[action="'.$url.'"]');
|
|
156
|
+
|
|
157
|
+ // On vérifie la présence en base des enregistrements
|
|
158
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
159
|
+ ->findBy(array('user' => $this->getUser()->getId()))
|
|
160
|
+ ;
|
|
161
|
+
|
|
162
|
+ $this->assertEquals(2, count($prefereds));
|
|
163
|
+
|
|
164
|
+ // On vérifie la présence en base des enregistrements
|
|
165
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
166
|
+ ->findBy(array(
|
|
167
|
+ 'user' => $this->getUser()->getId(),
|
|
168
|
+ 'tag' => $hardtek_id
|
|
169
|
+ ))
|
|
170
|
+ ;
|
|
171
|
+
|
|
172
|
+ $this->assertEquals(1, count($prefereds));
|
|
173
|
+
|
|
174
|
+ // On vérifie la présence en base des enregistrements
|
|
175
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
176
|
+ ->findBy(array(
|
|
177
|
+ 'user' => $this->getUser()->getId(),
|
|
178
|
+ 'tag' => $tribe_id
|
|
179
|
+ ))
|
|
180
|
+ ;
|
|
181
|
+
|
|
182
|
+ $this->assertEquals(1, count($prefereds));
|
|
183
|
+ }
|
|
184
|
+
|
|
185
|
+ /**
|
|
186
|
+ * Test de al procédure de changement d'email.
|
|
187
|
+ */
|
|
188
|
+ public function testChangeEmail()
|
|
189
|
+ {
|
|
190
|
+ $this->client = self::createClient();
|
|
191
|
+ $this->connectUser('bob', 'toor');
|
|
192
|
+ $bob = $this->findUserByUsername('bob');
|
|
193
|
+
|
|
194
|
+ // Ouverture de la page Mon compte
|
|
195
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
|
196
|
+
|
|
197
|
+ // Le mail en cours n'est pas celui que nous voulons mettre
|
|
198
|
+ $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
|
199
|
+ // Nous n'avons pas encore demandé de nouveau mail
|
|
200
|
+ $this->assertTrue($bob->getEmailRequested() == null);
|
|
201
|
+ $this->assertTrue($bob->getEmailRequestedDatetime() == null);
|
|
202
|
+
|
|
203
|
+ // On fait un premier essaie avec une email mal formulé
|
|
204
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
205
|
+ 'change_email_request'
|
|
206
|
+ )).'"]');
|
|
207
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
208
|
+
|
|
209
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
210
|
+ $form['form[email]'] = 'trololololooo@trolo';
|
|
211
|
+ $this->submit($form);
|
|
212
|
+
|
|
213
|
+ // Il n'y as pas de redirection
|
|
214
|
+ $this->isResponseSuccess();
|
|
215
|
+
|
|
216
|
+ $bob = $this->findUserByUsername('bob');
|
|
217
|
+ // Les champs n'ont pas bougés
|
|
218
|
+ $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
|
219
|
+ // Nous n'avons pas encore demandé de nouveau mail
|
|
220
|
+ $this->assertTrue($bob->getEmailRequested() == null);
|
|
221
|
+ $this->assertTrue($bob->getEmailRequestedDatetime() == null);
|
|
222
|
+
|
|
223
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
224
|
+ 'change_email_request'
|
|
225
|
+ )).'"]');
|
|
226
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
227
|
+
|
|
228
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
229
|
+ $form['form[email]'] = 'trololololooo@trolo.com';
|
|
230
|
+ $this->submit($form);
|
|
231
|
+
|
|
232
|
+ // Ce coup-ci c'est bien une redirection
|
|
233
|
+ $this->isResponseRedirection();
|
|
234
|
+
|
|
235
|
+ // Un mail a été envoyé
|
|
236
|
+ $mc = $this->getMailerMessageDataCollector();
|
|
237
|
+ $this->assertEquals(1, $mc->getMessageCount());
|
|
238
|
+
|
|
239
|
+ $mails = $mc->getMessages();
|
|
240
|
+ $mail = $mails[0];
|
|
241
|
+
|
|
242
|
+ // Les champs ont bougés
|
|
243
|
+ $bob = $this->findUserByUsername('bob');
|
|
244
|
+ $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
|
245
|
+ $this->assertFalse($bob->getEmailRequested() == null);
|
|
246
|
+ $this->assertTrue($bob->getEmailRequested() == 'trololololooo@trolo.com');
|
|
247
|
+ $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
|
248
|
+
|
|
249
|
+ $this->followRedirection();
|
|
250
|
+ $this->isResponseSuccess();
|
|
251
|
+
|
|
252
|
+ // On ouvre un lien erroné
|
|
253
|
+ $badurl = $this->generateUrl(
|
|
254
|
+ 'change_email_confirm',
|
|
255
|
+ array('token' => $this->getUser()->getConfirmationToken()),
|
|
256
|
+ true
|
|
257
|
+ );
|
|
258
|
+ $this->crawler = $this->client->request('GET', $badurl);
|
|
259
|
+ $this->isResponseRedirection();
|
|
260
|
+ $this->followRedirection();
|
|
261
|
+ $this->isResponseSuccess();
|
|
262
|
+ $this->exist('div.error');
|
|
263
|
+
|
|
264
|
+ // Et les champs ont pas bougés
|
|
265
|
+ $bob = $this->findUserByUsername('bob');
|
|
266
|
+ $this->assertFalse($bob->getEmail() == 'trololololooo@trolo.com');
|
|
267
|
+ $this->assertFalse($bob->getEmailRequested() == null);
|
|
268
|
+ $this->assertTrue($bob->getEmailRequested() == 'trololololooo@trolo.com');
|
|
269
|
+ $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
|
270
|
+
|
|
271
|
+ $this->assertTrue(!is_null(strpos($mail->getBody(), ($url = $this->generateUrl(
|
|
272
|
+ 'change_email_confirm',
|
|
273
|
+ array('token' => $token = hash('sha256', $bob->getConfirmationToken().'trololololooo@trolo.com')),
|
|
274
|
+ true
|
|
275
|
+ )))));
|
|
276
|
+
|
|
277
|
+ // On ouvre le bon lien
|
|
278
|
+ $this->crawler = $this->client->request('GET', $url);
|
|
279
|
+
|
|
280
|
+ // C'est un succés
|
|
281
|
+ $this->isResponseRedirection();
|
|
282
|
+ $this->followRedirection();
|
|
283
|
+ $this->isResponseSuccess();
|
|
284
|
+
|
|
285
|
+ $this->notExist('div.error');
|
|
286
|
+
|
|
287
|
+ // Et les champs ont bougés
|
|
288
|
+ $bob = $this->findUserByUsername('bob');
|
|
289
|
+ $this->assertTrue($bob->getEmail() == 'trololololooo@trolo.com');
|
|
290
|
+ $this->assertTrue($bob->getEmailRequested() == null);
|
|
291
|
+ $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
|
292
|
+
|
|
293
|
+ // Par contre si on refait une demande maintenant ca échoue (délais entre demandes)
|
|
294
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
295
|
+ 'change_email_request'
|
|
296
|
+ )).'"]');
|
|
297
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
298
|
+
|
|
299
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
300
|
+ $form['form[email]'] = 'trololololooo222@trolo.com';
|
|
301
|
+ $this->submit($form);
|
|
302
|
+
|
|
303
|
+ // Il n'y as pas de redirection
|
|
304
|
+ $this->isResponseRedirection();
|
|
305
|
+ $this->followRedirection();
|
|
306
|
+ $this->isResponseSuccess();
|
|
307
|
+ $this->exist('div.error');
|
|
308
|
+
|
|
309
|
+ // Et les champs ont bougés
|
|
310
|
+ $bob = $this->findUserByUsername('bob');
|
|
311
|
+ $this->assertTrue($bob->getEmail() == 'trololololooo@trolo.com');
|
|
312
|
+ $this->assertTrue($bob->getEmailRequested() == null);
|
|
313
|
+ $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
|
314
|
+
|
|
315
|
+ // Si par contre on manipule le dateTime on pourra
|
|
316
|
+ $bob = $this->findUserByUsername('bob');
|
|
317
|
+ $bob->setEmailRequestedDatetime(
|
|
318
|
+ $this->getUser()->getEmailRequestedDatetime()
|
|
319
|
+ - $this->getContainer()->getParameter('changeemail_security_delay')
|
|
320
|
+ );
|
|
321
|
+
|
|
322
|
+ $this->getDoctrine()->getEntityManager()->flush();
|
|
323
|
+
|
|
324
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
325
|
+ $form['form[email]'] = 'trololololooo222@trolo.com';
|
|
326
|
+ $this->submit($form);
|
|
327
|
+
|
|
328
|
+ // Ce coup-ci c'est bien une redirection
|
|
329
|
+ $this->isResponseRedirection();
|
|
330
|
+
|
|
331
|
+ // Un mail a été envoyé
|
|
332
|
+ $mc = $this->getMailerMessageDataCollector();
|
|
333
|
+ $this->assertEquals(1, $mc->getMessageCount());
|
|
334
|
+
|
|
335
|
+ $mails = $mc->getMessages();
|
|
336
|
+ $mail = $mails[0];
|
|
337
|
+
|
|
338
|
+ $this->assertTrue(!is_null(strpos($mail->getBody(), ($url = $this->generateUrl(
|
|
339
|
+ 'change_email_confirm',
|
|
340
|
+ array('token' => hash('sha256', $this->getUser()->getConfirmationToken().'trololololooo222@trolo.com')),
|
|
341
|
+ true
|
|
342
|
+ )))));
|
|
343
|
+
|
|
344
|
+ // Les champs ont bougés
|
|
345
|
+ $bob = $this->findUserByUsername('bob');
|
|
346
|
+ $this->assertFalse($bob->getEmail() == 'trololololooo222@trolo.com');
|
|
347
|
+ $this->assertFalse($bob->getEmailRequested() == null);
|
|
348
|
+ $this->assertTrue($bob->getEmailRequested() == 'trololololooo222@trolo.com');
|
|
349
|
+ $this->assertFalse($bob->getEmailRequestedDatetime() == null);
|
|
350
|
+
|
|
351
|
+ $this->followRedirection();
|
|
352
|
+ $this->isResponseSuccess();
|
|
353
|
+ }
|
354
|
354
|
|
355
|
355
|
public function testAddElementTagToFavorites()
|
356
|
356
|
{
|