|
@@ -72,4 +72,107 @@ class UserControllerTest extends FunctionalTest
|
72
|
72
|
;
|
73
|
73
|
$this->assertEquals(1, count($Favorites));
|
74
|
74
|
}
|
|
75
|
+
|
|
76
|
+ /**
|
|
77
|
+ * Test du changement de mot de passe par le baisis de la page 'Mon compte'
|
|
78
|
+ */
|
|
79
|
+ public function testChangePassword()
|
|
80
|
+ {
|
|
81
|
+ $this->client = self::createClient();
|
|
82
|
+ $this->connectUser('bux', 'toor');
|
|
83
|
+
|
|
84
|
+ // Ouverture de la page Mon compte
|
|
85
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
|
86
|
+
|
|
87
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
88
|
+ 'change_password'
|
|
89
|
+ )).'"]');
|
|
90
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_current"]');
|
|
91
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_new_first"]');
|
|
92
|
+ $this->exist('form[action="'.$url.'"] input[id="fos_user_change_password_form_new_second"]');
|
|
93
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
94
|
+
|
|
95
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
96
|
+ $form['fos_user_change_password_form[current]'] = 'toor';
|
|
97
|
+ $form['fos_user_change_password_form[new][first]'] = 'trololo';
|
|
98
|
+ $form['fos_user_change_password_form[new][second]'] = 'trololo';
|
|
99
|
+ $this->submit($form);
|
|
100
|
+
|
|
101
|
+ $this->isResponseRedirection();
|
|
102
|
+ $this->followRedirection();
|
|
103
|
+ $this->isResponseSuccess();
|
|
104
|
+
|
|
105
|
+ // On se déconnecte
|
|
106
|
+ $this->disconnectUser();
|
|
107
|
+
|
|
108
|
+ // Et on se connecte avec le nouveau mot de passe
|
|
109
|
+ $this->connectUser('bux', 'trololo');
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ /**
|
|
113
|
+ * Test du formulaire de mise a jour des tags par le baisis de la page 'Mon compte'
|
|
114
|
+ */
|
|
115
|
+ public function testUpdateFavoriteTags()
|
|
116
|
+ {
|
|
117
|
+ $this->client = self::createClient();
|
|
118
|
+ $this->connectUser('bob', 'toor');
|
|
119
|
+
|
|
120
|
+ // Ouverture de la page Mon compte
|
|
121
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('my_account'));
|
|
122
|
+
|
|
123
|
+ $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
124
|
+ $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
125
|
+
|
|
126
|
+ // Bob n'a aucun tag préféré
|
|
127
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
128
|
+ ->findBy(array('user' => $this->getUser()->getId()))
|
|
129
|
+ ;
|
|
130
|
+
|
|
131
|
+ $this->assertEquals(0, count($prefereds));
|
|
132
|
+
|
|
133
|
+ $this->exist('form[action="'.($url = $this->generateUrl(
|
|
134
|
+ 'update_tag_favorites', array('redirect' => 'account')
|
|
135
|
+ )).'"]');
|
|
136
|
+ $this->exist('form[action="'.$url.'"] input[type="submit"]');
|
|
137
|
+
|
|
138
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
139
|
+ $form['tag_favorites_form[tags]['.$hardtek_id.']'] = $hardtek_id;
|
|
140
|
+ $form['tag_favorites_form[tags]['.$tribe_id.']'] = $tribe_id;
|
|
141
|
+ $this->submit($form);
|
|
142
|
+
|
|
143
|
+ $this->isResponseRedirection();
|
|
144
|
+ $this->followRedirection();
|
|
145
|
+ $this->isResponseSuccess();
|
|
146
|
+
|
|
147
|
+ // On a été redirigé sur la page Mon compte
|
|
148
|
+ $this->exist('form[action="'.$url.'"]');
|
|
149
|
+
|
|
150
|
+ // On vérifie la présence en base des enregistrements
|
|
151
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
152
|
+ ->findBy(array('user' => $this->getUser()->getId()))
|
|
153
|
+ ;
|
|
154
|
+
|
|
155
|
+ $this->assertEquals(2, count($prefereds));
|
|
156
|
+
|
|
157
|
+ // On vérifie la présence en base des enregistrements
|
|
158
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
159
|
+ ->findBy(array(
|
|
160
|
+ 'user' => $this->getUser()->getId(),
|
|
161
|
+ 'tag' => $hardtek_id
|
|
162
|
+ ))
|
|
163
|
+ ;
|
|
164
|
+
|
|
165
|
+ $this->assertEquals(1, count($prefereds));
|
|
166
|
+
|
|
167
|
+ // On vérifie la présence en base des enregistrements
|
|
168
|
+ $prefereds = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
169
|
+ ->findBy(array(
|
|
170
|
+ 'user' => $this->getUser()->getId(),
|
|
171
|
+ 'tag' => $tribe_id
|
|
172
|
+ ))
|
|
173
|
+ ;
|
|
174
|
+
|
|
175
|
+ $this->assertEquals(1, count($prefereds));
|
|
176
|
+ }
|
|
177
|
+
|
75
|
178
|
}
|