|
@@ -0,0 +1,75 @@
|
|
1
|
+<?php
|
|
2
|
+
|
|
3
|
+namespace Muzich\CoreBundle\Tests\Controller;
|
|
4
|
+
|
|
5
|
+use Muzich\CoreBundle\lib\FunctionalTest;
|
|
6
|
+
|
|
7
|
+class UserControllerTest extends FunctionalTest
|
|
8
|
+{
|
|
9
|
+
|
|
10
|
+ public function testTagsFavoritesSuccess()
|
|
11
|
+ {
|
|
12
|
+ /**
|
|
13
|
+ * Inscription d'un utilisateur
|
|
14
|
+ */
|
|
15
|
+ $this->client = self::createClient();
|
|
16
|
+
|
|
17
|
+ $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
18
|
+ $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
19
|
+
|
|
20
|
+ $this->crawler = $this->client->request('GET', $this->generateUrl('index'));
|
|
21
|
+ $this->isResponseSuccess();
|
|
22
|
+
|
|
23
|
+ $this->procedure_registration_success(
|
|
24
|
+ 'raoulc',
|
|
25
|
+ 'raoulc.def4v65sds@gmail.com',
|
|
26
|
+ 'toor',
|
|
27
|
+ 'toor'
|
|
28
|
+ );
|
|
29
|
+
|
|
30
|
+ // Il ne doit y avoir aucun enregistrements de tags favoris
|
|
31
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
32
|
+ ->findBy(array(
|
|
33
|
+ 'user' => $this->getUser()->getId()
|
|
34
|
+ ))
|
|
35
|
+ ;
|
|
36
|
+
|
|
37
|
+ $this->assertEquals(0, count($Favorites));
|
|
38
|
+
|
|
39
|
+ // On a attérit sur la page de présentation et de sleection des tags favoris
|
|
40
|
+ $this->exist('form[action="'.($url = $this->generateUrl('update_tag_favorites')).'"]');
|
|
41
|
+
|
|
42
|
+ $form = $this->selectForm('form[action="'.$url.'"] input[type="submit"]');
|
|
43
|
+ $form['tag_favorites_form[tags]['.$hardtek_id.']'] = $hardtek_id;
|
|
44
|
+ $form['tag_favorites_form[tags]['.$tribe_id.']'] = $tribe_id;
|
|
45
|
+ $this->submit($form);
|
|
46
|
+
|
|
47
|
+ $this->isResponseRedirection();
|
|
48
|
+ $this->followRedirection();
|
|
49
|
+ $this->isResponseSuccess();
|
|
50
|
+
|
|
51
|
+ // Désormais il y a deux tags favoris pour cet utilisateur
|
|
52
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
53
|
+ ->findBy(array(
|
|
54
|
+ 'user' => $this->getUser()->getId()
|
|
55
|
+ ))
|
|
56
|
+ ;
|
|
57
|
+ $this->assertEquals(2, count($Favorites));
|
|
58
|
+
|
|
59
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
60
|
+ ->findBy(array(
|
|
61
|
+ 'user' => $this->getUser()->getId(),
|
|
62
|
+ 'tag' => $hardtek_id
|
|
63
|
+ ))
|
|
64
|
+ ;
|
|
65
|
+ $this->assertEquals(1, count($Favorites));
|
|
66
|
+
|
|
67
|
+ $Favorites = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersTagsFavorites')
|
|
68
|
+ ->findBy(array(
|
|
69
|
+ 'user' => $this->getUser()->getId(),
|
|
70
|
+ 'tag' => $tribe_id
|
|
71
|
+ ))
|
|
72
|
+ ;
|
|
73
|
+ $this->assertEquals(1, count($Favorites));
|
|
74
|
+ }
|
|
75
|
+}
|