|
@@ -141,9 +141,6 @@ class HomeControllerTest extends FunctionalTest
|
141
|
141
|
$hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
142
|
142
|
$tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
143
|
143
|
|
144
|
|
- // Un groupe open
|
145
|
|
- $fan_de_psy = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
146
|
|
-
|
147
|
144
|
/*
|
148
|
145
|
* Ajout d'un élément avec succés
|
149
|
146
|
*/
|
|
@@ -175,9 +172,6 @@ class HomeControllerTest extends FunctionalTest
|
175
|
172
|
$hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
176
|
173
|
$tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
177
|
174
|
|
178
|
|
- // Un groupe no open
|
179
|
|
- $dudeldrum = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('DUDELDRUM');
|
180
|
|
-
|
181
|
175
|
/*
|
182
|
176
|
* Ajouts d'éléments avec echec
|
183
|
177
|
*/
|
|
@@ -190,10 +184,10 @@ class HomeControllerTest extends FunctionalTest
|
190
|
184
|
);
|
191
|
185
|
|
192
|
186
|
$this->isResponseSuccess();
|
193
|
|
-
|
194
|
|
- $this->notExist('li:contains("Mon bel element")');
|
|
187
|
+
|
|
188
|
+ $this->notExist('li:contains("Mon bel element a4er563a1r")');
|
195
|
189
|
$element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
196
|
|
- ->findOneByName('Mon bel element')
|
|
190
|
+ ->findOneByName('Mon bel element a4er563a1r')
|
197
|
191
|
;
|
198
|
192
|
$this->assertTrue(is_null($element));
|
199
|
193
|
|
|
@@ -221,9 +215,9 @@ class HomeControllerTest extends FunctionalTest
|
221
|
215
|
|
222
|
216
|
$this->isResponseSuccess();
|
223
|
217
|
|
224
|
|
- $this->notExist('li:contains("Mon bel element")');
|
|
218
|
+ $this->notExist('li:contains("Mon bel element gfez7f")');
|
225
|
219
|
$element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
226
|
|
- ->findOneByName('Mon bel element')
|
|
220
|
+ ->findOneByName('Mon bel element gfez7f')
|
227
|
221
|
;
|
228
|
222
|
$this->assertTrue(is_null($element));
|
229
|
223
|
|
|
@@ -243,41 +237,110 @@ class HomeControllerTest extends FunctionalTest
|
243
|
237
|
|
244
|
238
|
}
|
245
|
239
|
|
246
|
|
- public function testAddElementAtGroupFailure()
|
|
240
|
+ /**
|
|
241
|
+ * L'ajout d'un Element a un de ses groupe ne doit pas poser de problème
|
|
242
|
+ */
|
|
243
|
+ public function testAddElementAtMyGroupSuccess()
|
247
|
244
|
{
|
248
|
245
|
$this->connectUser('bux', 'toor');
|
|
246
|
+ // Un groupe open, donc pas de soucis
|
|
247
|
+ $fan_de_psy = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
|
248
|
+
|
|
249
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
250
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
251
|
+
|
|
252
|
+ $this->isResponseSuccess();
|
|
253
|
+ $this->procedure_add_element(
|
|
254
|
+ 'Element mis dans le groupe de psytrance',
|
|
255
|
+ 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
256
|
+ array($hardtek->getId(), $tribe->getId()),
|
|
257
|
+ $fan_de_psy->getSlug()
|
|
258
|
+ );
|
|
259
|
+
|
|
260
|
+ $this->isResponseRedirection();
|
|
261
|
+ $this->followRedirection();
|
|
262
|
+ $this->isResponseSuccess();
|
|
263
|
+
|
|
264
|
+ $this->exist('li:contains("Element mis dans le groupe de psytrance")');
|
|
265
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
266
|
+ ->findOneByName('Element mis dans le groupe de psytrance')
|
|
267
|
+ ;
|
|
268
|
+ $this->assertTrue(!is_null($element));
|
|
269
|
+
|
|
270
|
+ if (!is_null($element))
|
|
271
|
+ {
|
|
272
|
+ $this->assertEquals($fan_de_psy->getId(), $element->getGroup()->getId());
|
|
273
|
+ }
|
|
274
|
+ else
|
|
275
|
+ {
|
|
276
|
+ $this->assertTrue(false);
|
|
277
|
+ }
|
|
278
|
+
|
|
279
|
+ $this->disconnectUser();
|
249
|
280
|
|
250
|
281
|
/*
|
251
|
|
- * Ajout d'un élément lié a un groupe (success)
|
|
282
|
+ * Ajout d'un element dans un groupe que l'on posséde.
|
252
|
283
|
*/
|
|
284
|
+ $this->connectUser('joelle', 'toor');
|
|
285
|
+ $this->isResponseSuccess();
|
|
286
|
+
|
|
287
|
+ // Ce groupe appartient a joelle
|
|
288
|
+ $groupe_de_joelle = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Le groupe de joelle');
|
|
289
|
+
|
253
|
290
|
$this->procedure_add_element(
|
254
|
|
- 'Mon bel element',
|
|
291
|
+ 'Element mis dans le groupe de joelle',
|
255
|
292
|
'http://www.youtube.com/watch?v=WC8qb_of04E',
|
256
|
293
|
array($hardtek->getId(), $tribe->getId()),
|
257
|
|
- $fan_de_psy->getId()
|
|
294
|
+ $groupe_de_joelle->getSlug()
|
258
|
295
|
);
|
259
|
296
|
|
260
|
297
|
$this->isResponseRedirection();
|
261
|
298
|
$this->followRedirection();
|
262
|
299
|
$this->isResponseSuccess();
|
263
|
300
|
|
264
|
|
- $this->exist('li:contains("Mon bel element")');
|
|
301
|
+ $this->exist('li:contains("Element mis dans le groupe de joelle")');
|
265
|
302
|
$element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
266
|
|
- ->findOneByName('Mon bel element')
|
|
303
|
+ ->findOneByName('Element mis dans le groupe de joelle')
|
267
|
304
|
;
|
268
|
305
|
$this->assertTrue(!is_null($element));
|
|
306
|
+
|
269
|
307
|
if (!is_null($element))
|
270
|
308
|
{
|
271
|
|
- $this->assertEquals($fan_de_psy->getId(), $element->getGroup()->getId());
|
|
309
|
+ $this->assertEquals($groupe_de_joelle->getId(), $element->getGroup()->getId());
|
|
310
|
+ }
|
|
311
|
+ else
|
|
312
|
+ {
|
|
313
|
+ $this->assertTrue(false);
|
272
|
314
|
}
|
273
|
315
|
}
|
274
|
316
|
|
275
|
317
|
/**
|
276
|
|
- * L'ajout d'un Element a un de ses groupe ne doit pas poser de problème
|
|
318
|
+ * L'ajout a un group qui n'est pas a sois, ou qui n'est pas open
|
|
319
|
+ * doit être impossible.
|
277
|
320
|
*/
|
278
|
|
- public function testAddElementAtMyGroupSuccess()
|
|
321
|
+ public function testAddElementAtGroupFailure()
|
279
|
322
|
{
|
|
323
|
+ $this->connectUser('bux', 'toor');
|
|
324
|
+ // Un groupe no open
|
|
325
|
+ $dudeldrum = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('DUDELDRUM');
|
|
326
|
+
|
|
327
|
+ $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
328
|
+ $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
329
|
+
|
|
330
|
+ // Nous tentons d'ouvrir l'url d'ajout d'élément avec un groupe qui n'est pas ouvert
|
|
331
|
+ // et qui n'appartient pas a l'utilisateur connecté
|
|
332
|
+ $this->crawler = $this->client->request(
|
|
333
|
+ 'POST',
|
|
334
|
+ $this->generateUrl('element_add', array('group_slug' => $dudeldrum->getSlug())),
|
|
335
|
+ array(
|
|
336
|
+ 'element_add[name]' => 'Yohoho trululu',
|
|
337
|
+ 'element_add[url]' => 'http://www.youtube.com/watch?v=WC8qb_of04E',
|
|
338
|
+ 'element_add[tags]['.$hardtek->getId().']' => $hardtek->getId(),
|
|
339
|
+ 'element_add[tags]['.$tribe->getId().']' => $tribe->getId()
|
|
340
|
+ )
|
|
341
|
+ );
|
280
|
342
|
|
|
343
|
+ $this->isResponseNotFound();
|
281
|
344
|
}
|
282
|
345
|
|
283
|
346
|
}
|