|
@@ -166,4 +166,57 @@ class FavoriteControllerTest extends FunctionalTest
|
166
|
166
|
$this->assertTrue(is_null($favorite));
|
167
|
167
|
}
|
168
|
168
|
|
|
169
|
+ public function testAjax()
|
|
170
|
+ {
|
|
171
|
+ $this->client = self::createClient();
|
|
172
|
+ $this->connectUser('bux', 'toor');
|
|
173
|
+
|
|
174
|
+ $bux = $this->getUser();
|
|
175
|
+
|
|
176
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
177
|
+ ->findOneByName('Ed Cox - La fanfare des teuffeurs (Hardcordian)')
|
|
178
|
+ ;
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+ $url = $this->generateUrl('favorite_add', array(
|
|
183
|
+ 'id' => $element->getId(),
|
|
184
|
+ 'token' => $bux->getPersonalHash()
|
|
185
|
+ ));
|
|
186
|
+
|
|
187
|
+ $crawler = $this->client->request('GET', $url, array(), array(), array(
|
|
188
|
+ 'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
|
189
|
+ ));
|
|
190
|
+
|
|
191
|
+ $this->isResponseSuccess();
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+ $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
|
|
195
|
+ ->findOneBy(array(
|
|
196
|
+ 'user' => $bux->getId(),
|
|
197
|
+ 'element' => $element->getId()
|
|
198
|
+ ));
|
|
199
|
+
|
|
200
|
+ $this->assertTrue(!is_null($fav));
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+ $url = $this->generateUrl('favorite_remove', array(
|
|
204
|
+ 'id' => $element->getId(),
|
|
205
|
+ 'token' => $bux->getPersonalHash()
|
|
206
|
+ ));
|
|
207
|
+
|
|
208
|
+ $crawler = $this->client->request('GET', $url, array(), array(), array(
|
|
209
|
+ 'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
|
210
|
+ ));
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+ $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
|
|
214
|
+ ->findOneBy(array(
|
|
215
|
+ 'user' => $bux->getId(),
|
|
216
|
+ 'element' => $element->getId()
|
|
217
|
+ ));
|
|
218
|
+
|
|
219
|
+ $this->assertTrue(is_null($fav));
|
|
220
|
+ }
|
|
221
|
+
|
169
|
222
|
}
|