|
@@ -3,154 +3,407 @@
|
3
|
3
|
namespace Muzich\CoreBundle\Tests\Controller;
|
4
|
4
|
|
5
|
5
|
use Muzich\CoreBundle\lib\FunctionalTest;
|
|
6
|
+use Muzich\CoreBundle\Entity\FollowUser;
|
|
7
|
+use Muzich\CoreBundle\Entity\FollowGroup;
|
6
|
8
|
|
7
|
9
|
class ShowControllerTest extends FunctionalTest
|
8
|
10
|
{
|
9
|
11
|
|
10
|
|
- public function testViewMoreOnProfile()
|
|
12
|
+// public function testViewMoreOnProfile()
|
|
13
|
+// {
|
|
14
|
+// $this->client = self::createClient();
|
|
15
|
+// $this->connectUser('bux', 'toor');
|
|
16
|
+//
|
|
17
|
+// $bux = $this->getUser();
|
|
18
|
+//
|
|
19
|
+// $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
20
|
+// $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
21
|
+//
|
|
22
|
+// // En premier lieux on va devoir ajouter des éléments.
|
|
23
|
+// $this->addElementAjax('PoPElement 1', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
|
24
|
+// $this->addElementAjax('PoPElement 2', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
|
25
|
+// $this->addElementAjax('PoPElement 3', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
|
26
|
+// $this->addElementAjax('PoPElement 4', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
|
27
|
+//
|
|
28
|
+// // D'après les fixtures on aura 2 éléments en plus des 10 (paramétre) de la page
|
|
29
|
+// // Ouverture de la page profil
|
|
30
|
+// $this->crawler = $this->client->request('GET', $this->generateUrl('show_user', array('slug' => $bux->getSlug())));
|
|
31
|
+// $this->isResponseSuccess();
|
|
32
|
+//
|
|
33
|
+// $this->exist('span.element_name:contains("PoPElement 4")');
|
|
34
|
+// $this->exist('span.element_name:contains("PoPElement 3")');
|
|
35
|
+// $this->exist('span.element_name:contains("PoPElement 2")');
|
|
36
|
+// $this->exist('span.element_name:contains("PoPElement 1")');
|
|
37
|
+// $this->exist('span.element_name:contains("Ed Cox - La fanfare des teuffeurs (Hardcordian)")');
|
|
38
|
+// $this->exist('span.element_name:contains("Babylon Pression - Des Tasers et des Pauvres")');
|
|
39
|
+// $this->exist('span.element_name:contains("AZYD AZYLUM Live au Café Provisoire")');
|
|
40
|
+// $this->exist('span.element_name:contains("SOULFLY - Prophecy")');
|
|
41
|
+// $this->exist('span.element_name:contains("KoinkOin - H5N1")');
|
|
42
|
+// $this->exist('span.element_name:contains("Antropod - Polakatek")');
|
|
43
|
+// $this->notExist('span.element_name:contains("Dtc che passdrop")');
|
|
44
|
+// $this->notExist('span.element_name:contains("Heretik System Popof - Resistance")');
|
|
45
|
+//
|
|
46
|
+// // L'élément de référence est celui en bas de la liste
|
|
47
|
+// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
48
|
+// ->findOneByName('Antropod - Polakatek')
|
|
49
|
+// ;
|
|
50
|
+// $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
|
|
51
|
+// ->getElementsTags($bux->getId(), $bux->getId())
|
|
52
|
+// ;
|
|
53
|
+//
|
|
54
|
+// $ids = array();
|
|
55
|
+// foreach ($tags as $tag)
|
|
56
|
+// {
|
|
57
|
+// $ids[] = $tag->getId();
|
|
58
|
+// }
|
|
59
|
+//
|
|
60
|
+// // On fait la demande pour en voir plus
|
|
61
|
+// $url = $this->generateUrl('show_elements_get', array(
|
|
62
|
+// 'type' => 'user',
|
|
63
|
+// 'object_id' => $bux->getId(),
|
|
64
|
+// 'tags_ids_json' => json_encode($ids),
|
|
65
|
+// 'id_limit' => $element->getId()
|
|
66
|
+// ));
|
|
67
|
+// $crawler = $this->client->request(
|
|
68
|
+// 'GET',
|
|
69
|
+// $url,
|
|
70
|
+// array(),
|
|
71
|
+// array(),
|
|
72
|
+// array('HTTP_X-Requested-With' => 'XMLHttpRequest')
|
|
73
|
+// );
|
|
74
|
+//
|
|
75
|
+// $response = json_decode($this->client->getResponse()->getContent(), true);
|
|
76
|
+// $this->assertEquals($response['status'], 'success');
|
|
77
|
+// $this->assertTrue(strpos($response['html'], 'Dtc che passdrop') !== false);
|
|
78
|
+// $this->assertTrue(strpos($response['html'], 'Heretik System Popof - Resistance') !== false);
|
|
79
|
+// }
|
|
80
|
+//
|
|
81
|
+// public function testViewMoreOnGroup()
|
|
82
|
+// {
|
|
83
|
+// $this->client = self::createClient();
|
|
84
|
+// $this->connectUser('bux', 'toor');
|
|
85
|
+//
|
|
86
|
+// $bux = $this->getUser();
|
|
87
|
+// $fan_de_psy = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
|
88
|
+//
|
|
89
|
+// $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
|
90
|
+// $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
|
91
|
+//
|
|
92
|
+// // En premier lieux on va devoir ajouter des éléments.
|
|
93
|
+// $this->addElementAjax('PsyElement 1', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
94
|
+// $this->addElementAjax('PsyElement 2', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
95
|
+// $this->addElementAjax('PsyElement 3', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
96
|
+// $this->addElementAjax('PsyElement 4', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
97
|
+// $this->addElementAjax('PsyElement 5', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
98
|
+// $this->addElementAjax('PsyElement 6', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
99
|
+// $this->addElementAjax('PsyElement 7', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
100
|
+// $this->addElementAjax('PsyElement 8', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
101
|
+// $this->addElementAjax('PsyElement 9', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
102
|
+// $this->addElementAjax('PsyElement 10', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
|
103
|
+//
|
|
104
|
+// // D'après les fixtures on aura 2 éléments en plus des 10 (paramétre) de la page
|
|
105
|
+// // Ouverture de la page profil
|
|
106
|
+// $this->crawler = $this->client->request('GET', $this->generateUrl('show_group', array('slug' => $fan_de_psy->getSlug())));
|
|
107
|
+// $this->isResponseSuccess();
|
|
108
|
+//
|
|
109
|
+// $this->exist('span.element_name:contains("PsyElement 10")');
|
|
110
|
+// $this->exist('span.element_name:contains("PsyElement 9")');
|
|
111
|
+// $this->exist('span.element_name:contains("PsyElement 8")');
|
|
112
|
+// $this->exist('span.element_name:contains("PsyElement 7")');
|
|
113
|
+// $this->exist('span.element_name:contains("PsyElement 6")');
|
|
114
|
+// $this->exist('span.element_name:contains("PsyElement 5")');
|
|
115
|
+// $this->exist('span.element_name:contains("PsyElement 4")');
|
|
116
|
+// $this->exist('span.element_name:contains("PsyElement 3")');
|
|
117
|
+// $this->exist('span.element_name:contains("PsyElement 5")');
|
|
118
|
+// $this->exist('span.element_name:contains("PsyElement 1")');
|
|
119
|
+// $this->notExist('span.element_name:contains("Infected mushroom - Muse Breaks")');
|
|
120
|
+// $this->notExist('span.element_name:contains("Infected Mushroom - Psycho")');
|
|
121
|
+//
|
|
122
|
+// // L'élément de référence est celui en bas de la liste, donc le premier ajouté
|
|
123
|
+// // la haut (vuq ue l'on en a ajouté 10)
|
|
124
|
+// $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
125
|
+// ->findOneByName('PsyElement 1')
|
|
126
|
+// ;
|
|
127
|
+// $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
|
|
128
|
+// ->getElementsTags($fan_de_psy->getId(), $bux->getId())
|
|
129
|
+// ;
|
|
130
|
+//
|
|
131
|
+// $ids = array();
|
|
132
|
+// foreach ($tags as $tag)
|
|
133
|
+// {
|
|
134
|
+// $ids[] = $tag->getId();
|
|
135
|
+// }
|
|
136
|
+//
|
|
137
|
+// // On fait la demande pour en voir plus
|
|
138
|
+// $url = $this->generateUrl('show_elements_get', array(
|
|
139
|
+// 'type' => 'group',
|
|
140
|
+// 'object_id' => $fan_de_psy->getId(),
|
|
141
|
+// 'tags_ids_json' => json_encode($ids),
|
|
142
|
+// 'id_limit' => $element->getId()
|
|
143
|
+// ));
|
|
144
|
+// $crawler = $this->client->request(
|
|
145
|
+// 'GET',
|
|
146
|
+// $url,
|
|
147
|
+// array(),
|
|
148
|
+// array(),
|
|
149
|
+// array('HTTP_X-Requested-With' => 'XMLHttpRequest')
|
|
150
|
+// );
|
|
151
|
+//
|
|
152
|
+// $response = json_decode($this->client->getResponse()->getContent(), true);
|
|
153
|
+// $this->assertEquals($response['status'], 'success');
|
|
154
|
+// $this->assertTrue(strpos($response['html'], 'Infected mushroom - Muse Breaks') !== false);
|
|
155
|
+// $this->assertTrue(strpos($response['html'], 'Infected Mushroom - Psycho') !== false);
|
|
156
|
+// }
|
|
157
|
+
|
|
158
|
+ /**
|
|
159
|
+ * Contrôle de l'affichage des informations x partages x suiveur ...
|
|
160
|
+ */
|
|
161
|
+ public function testInfosUser()
|
11
|
162
|
{
|
12
|
163
|
$this->client = self::createClient();
|
13
|
164
|
$this->connectUser('bux', 'toor');
|
14
|
165
|
|
15
|
|
- $bux = $this->getUser();
|
|
166
|
+ $bux = $this->getUser();
|
|
167
|
+ $paul = $this->getUser('paul');
|
|
168
|
+ $joelle = $this->getUser('joelle');
|
16
|
169
|
|
17
|
|
- $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
18
|
|
- $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
19
|
|
-
|
20
|
|
- // En premier lieux on va devoir ajouter des éléments.
|
21
|
|
- $this->addElementAjax('PoPElement 1', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
22
|
|
- $this->addElementAjax('PoPElement 2', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
23
|
|
- $this->addElementAjax('PoPElement 3', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
24
|
|
- $this->addElementAjax('PoPElement 4', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)));
|
25
|
|
-
|
26
|
|
- // D'après les fixtures on aura 2 éléments en plus des 10 (paramétre) de la page
|
27
|
|
- // Ouverture de la page profil
|
28
|
|
- $this->crawler = $this->client->request('GET', $this->generateUrl('show_user', array('slug' => $bux->getSlug())));
|
|
170
|
+// $translator = new Translator('fr', new MessageSelector());
|
|
171
|
+// $translator->trans($id, $parameters, $domain, $locale);
|
|
172
|
+
|
|
173
|
+ // On va sur la page profil de paul
|
|
174
|
+ $this->crawler = $this->client->request('GET',
|
|
175
|
+ $this->generateUrl('show_user', array('slug' => $paul->getSlug()))
|
|
176
|
+ );
|
29
|
177
|
$this->isResponseSuccess();
|
30
|
178
|
|
31
|
|
- $this->exist('span.element_name:contains("PoPElement 4")');
|
32
|
|
- $this->exist('span.element_name:contains("PoPElement 3")');
|
33
|
|
- $this->exist('span.element_name:contains("PoPElement 2")');
|
34
|
|
- $this->exist('span.element_name:contains("PoPElement 1")');
|
35
|
|
- $this->exist('span.element_name:contains("Ed Cox - La fanfare des teuffeurs (Hardcordian)")');
|
36
|
|
- $this->exist('span.element_name:contains("Babylon Pression - Des Tasers et des Pauvres")');
|
37
|
|
- $this->exist('span.element_name:contains("AZYD AZYLUM Live au Café Provisoire")');
|
38
|
|
- $this->exist('span.element_name:contains("SOULFLY - Prophecy")');
|
39
|
|
- $this->exist('span.element_name:contains("KoinkOin - H5N1")');
|
40
|
|
- $this->exist('span.element_name:contains("Antropod - Polakatek")');
|
41
|
|
- $this->notExist('span.element_name:contains("Dtc che passdrop")');
|
42
|
|
- $this->notExist('span.element_name:contains("Heretik System Popof - Resistance")');
|
43
|
|
-
|
44
|
|
- // L'élément de référence est celui en bas de la liste
|
45
|
|
- $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
46
|
|
- ->findOneByName('Antropod - Polakatek')
|
|
179
|
+ // D'après les fixtures
|
|
180
|
+ $this->exist('p.show_info:contains("'.
|
|
181
|
+ $this->getContainer()->get('translator')->trans('show.user.elements.count', array(
|
|
182
|
+ '%count_owned%' => 4,
|
|
183
|
+ '%count_favorited%' => 0,
|
|
184
|
+ '%count_favorited_users%' => 0
|
|
185
|
+ ), 'elements')
|
|
186
|
+ .'")');
|
|
187
|
+ $this->exist('p.show_info:contains("'.
|
|
188
|
+ $this->getContainer()->get('translator')->trans('show.user.followers.one_count', array(
|
|
189
|
+ '%count%' => 1,
|
|
190
|
+ '%name%' => $paul->getName()
|
|
191
|
+ ), 'elements')
|
|
192
|
+ .'")');
|
|
193
|
+
|
|
194
|
+ // On supprime le fait que bux suivent paul
|
|
195
|
+ $follow = $this->getDoctrine()->getRepository('MuzichCoreBundle:FollowUser')
|
|
196
|
+ ->findOneBy(array(
|
|
197
|
+ 'follower' => $bux->getId(),
|
|
198
|
+ 'followed' => $paul->getId()
|
|
199
|
+ ))
|
47
|
200
|
;
|
48
|
|
- $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')
|
49
|
|
- ->getElementsTags($bux->getId(), $bux->getId())
|
|
201
|
+ $this->getDoctrine()->getEntityManager()->remove($follow);
|
|
202
|
+ $this->getDoctrine()->getEntityManager()->flush();
|
|
203
|
+
|
|
204
|
+ // On rafraichie la page
|
|
205
|
+ $this->crawler = $this->client->request('GET',
|
|
206
|
+ $this->generateUrl('show_user', array('slug' => $paul->getSlug()))
|
|
207
|
+ );
|
|
208
|
+ $this->isResponseSuccess();
|
|
209
|
+
|
|
210
|
+ // D'après les fixtures
|
|
211
|
+ $this->exist('p.show_info:contains("'.
|
|
212
|
+ $this->getContainer()->get('translator')->trans('show.user.elements.count', array(
|
|
213
|
+ '%count_owned%' => 4,
|
|
214
|
+ '%count_favorited%' => 0,
|
|
215
|
+ '%count_favorited_users%' => 0
|
|
216
|
+ ), 'elements')
|
|
217
|
+ .'")');
|
|
218
|
+ $this->exist('p.show_info:contains("'.
|
|
219
|
+ $this->getContainer()->get('translator')->trans('show.user.followers.zero_count', array(
|
|
220
|
+ '%name%' => $paul->getName()
|
|
221
|
+ ), 'elements')
|
|
222
|
+ .'")');
|
|
223
|
+
|
|
224
|
+ // bux met en favoris un élément
|
|
225
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
226
|
+ ->findOneByName('Infected Mushroom - Psycho')
|
50
|
227
|
;
|
51
|
228
|
|
52
|
|
- $ids = array();
|
53
|
|
- foreach ($tags as $tag)
|
54
|
|
- {
|
55
|
|
- $ids[] = $tag->getId();
|
56
|
|
- }
|
57
|
|
-
|
58
|
|
- // On fait la demande pour en voir plus
|
59
|
|
- $url = $this->generateUrl('show_elements_get', array(
|
60
|
|
- 'type' => 'user',
|
61
|
|
- 'object_id' => $bux->getId(),
|
62
|
|
- 'tags_ids_json' => json_encode($ids),
|
63
|
|
- 'id_limit' => $element->getId()
|
|
229
|
+ $url = $this->generateUrl('favorite_add', array(
|
|
230
|
+ 'id' => $element->getId(),
|
|
231
|
+ 'token' => $bux->getPersonalHash()
|
64
|
232
|
));
|
65
|
|
- $crawler = $this->client->request(
|
66
|
|
- 'GET',
|
67
|
|
- $url,
|
68
|
|
- array(),
|
69
|
|
- array(),
|
70
|
|
- array('HTTP_X-Requested-With' => 'XMLHttpRequest')
|
|
233
|
+
|
|
234
|
+ $crawler = $this->client->request('GET', $url, array(), array(), array(
|
|
235
|
+ 'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
|
236
|
+ ));
|
|
237
|
+
|
|
238
|
+ $this->isResponseSuccess();
|
|
239
|
+
|
|
240
|
+ // On contrôle la présence du favoris
|
|
241
|
+ $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
|
|
242
|
+ ->findOneBy(array(
|
|
243
|
+ 'user' => $bux->getId(),
|
|
244
|
+ 'element' => $element->getId()
|
|
245
|
+ ));
|
|
246
|
+
|
|
247
|
+ $this->assertTrue(!is_null($fav));
|
|
248
|
+
|
|
249
|
+ // On rafraichie la page
|
|
250
|
+ $this->crawler = $this->client->request('GET',
|
|
251
|
+ $this->generateUrl('show_user', array('slug' => $paul->getSlug()))
|
71
|
252
|
);
|
|
253
|
+ $this->isResponseSuccess();
|
72
|
254
|
|
73
|
|
- $response = json_decode($this->client->getResponse()->getContent(), true);
|
74
|
|
- $this->assertEquals($response['status'], 'success');
|
75
|
|
- $this->assertTrue(strpos($response['html'], 'Dtc che passdrop') !== false);
|
76
|
|
- $this->assertTrue(strpos($response['html'], 'Heretik System Popof - Resistance') !== false);
|
77
|
|
- }
|
78
|
|
-
|
79
|
|
- public function testViewMoreOnGroup()
|
80
|
|
- {
|
81
|
|
- $this->client = self::createClient();
|
82
|
|
- $this->connectUser('bux', 'toor');
|
|
255
|
+ // D'après les fixtures
|
|
256
|
+ $this->exist('p.show_info:contains("'.
|
|
257
|
+ $this->getContainer()->get('translator')->trans('show.user.elements.count', array(
|
|
258
|
+ '%count_owned%' => 4,
|
|
259
|
+ '%count_favorited%' => 1,
|
|
260
|
+ '%count_favorited_users%' => 1
|
|
261
|
+ ), 'elements')
|
|
262
|
+ .'")');
|
|
263
|
+ $this->exist('p.show_info:contains("'.
|
|
264
|
+ $this->getContainer()->get('translator')->trans('show.user.followers.zero_count', array(
|
|
265
|
+ '%name%' => $paul->getName()
|
|
266
|
+ ), 'elements')
|
|
267
|
+ .'")');
|
83
|
268
|
|
84
|
|
- $bux = $this->getUser();
|
85
|
|
- $fan_de_psy = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
|
86
|
|
-
|
87
|
|
- $hardtek_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek')->getId();
|
88
|
|
- $tribe_id = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe')->getId();
|
89
|
|
-
|
90
|
|
- // En premier lieux on va devoir ajouter des éléments.
|
91
|
|
- $this->addElementAjax('PsyElement 1', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
92
|
|
- $this->addElementAjax('PsyElement 2', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
93
|
|
- $this->addElementAjax('PsyElement 3', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
94
|
|
- $this->addElementAjax('PsyElement 4', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
95
|
|
- $this->addElementAjax('PsyElement 5', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
96
|
|
- $this->addElementAjax('PsyElement 6', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
97
|
|
- $this->addElementAjax('PsyElement 7', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
98
|
|
- $this->addElementAjax('PsyElement 8', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
99
|
|
- $this->addElementAjax('PsyElement 9', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
100
|
|
- $this->addElementAjax('PsyElement 10', 'http://labas.com', json_encode(array($hardtek_id, $tribe_id)), $fan_de_psy->getSlug());
|
101
|
|
-
|
102
|
|
- // D'après les fixtures on aura 2 éléments en plus des 10 (paramétre) de la page
|
103
|
|
- // Ouverture de la page profil
|
104
|
|
- $this->crawler = $this->client->request('GET', $this->generateUrl('show_group', array('slug' => $fan_de_psy->getSlug())));
|
|
269
|
+ // bux met en favoris un autre élément
|
|
270
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
271
|
+ ->findOneByName('CardioT3K - Juggernaut Trap')
|
|
272
|
+ ;
|
|
273
|
+
|
|
274
|
+ $url = $this->generateUrl('favorite_add', array(
|
|
275
|
+ 'id' => $element->getId(),
|
|
276
|
+ 'token' => $bux->getPersonalHash()
|
|
277
|
+ ));
|
|
278
|
+
|
|
279
|
+ $crawler = $this->client->request('GET', $url, array(), array(), array(
|
|
280
|
+ 'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
|
281
|
+ ));
|
|
282
|
+
|
|
283
|
+ $this->isResponseSuccess();
|
|
284
|
+
|
|
285
|
+ // On contrôle la présence du favoris
|
|
286
|
+ $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
|
|
287
|
+ ->findOneBy(array(
|
|
288
|
+ 'user' => $bux->getId(),
|
|
289
|
+ 'element' => $element->getId()
|
|
290
|
+ ));
|
|
291
|
+
|
|
292
|
+ $this->assertTrue(!is_null($fav));
|
|
293
|
+
|
|
294
|
+ // On rafraichie la page
|
|
295
|
+ $this->crawler = $this->client->request('GET',
|
|
296
|
+ $this->generateUrl('show_user', array('slug' => $paul->getSlug()))
|
|
297
|
+ );
|
105
|
298
|
$this->isResponseSuccess();
|
106
|
299
|
|
107
|
|
- $this->exist('span.element_name:contains("PsyElement 10")');
|
108
|
|
- $this->exist('span.element_name:contains("PsyElement 9")');
|
109
|
|
- $this->exist('span.element_name:contains("PsyElement 8")');
|
110
|
|
- $this->exist('span.element_name:contains("PsyElement 7")');
|
111
|
|
- $this->exist('span.element_name:contains("PsyElement 6")');
|
112
|
|
- $this->exist('span.element_name:contains("PsyElement 5")');
|
113
|
|
- $this->exist('span.element_name:contains("PsyElement 4")');
|
114
|
|
- $this->exist('span.element_name:contains("PsyElement 3")');
|
115
|
|
- $this->exist('span.element_name:contains("PsyElement 5")');
|
116
|
|
- $this->exist('span.element_name:contains("PsyElement 1")');
|
117
|
|
- $this->notExist('span.element_name:contains("Infected mushroom - Muse Breaks")');
|
118
|
|
- $this->notExist('span.element_name:contains("Infected Mushroom - Psycho")');
|
119
|
|
-
|
120
|
|
- // L'élément de référence est celui en bas de la liste, donc le premier ajouté
|
121
|
|
- // la haut (vuq ue l'on en a ajouté 10)
|
|
300
|
+ // D'après les fixtures
|
|
301
|
+ $this->exist('p.show_info:contains("'.
|
|
302
|
+ $this->getContainer()->get('translator')->trans('show.user.elements.count', array(
|
|
303
|
+ '%count_owned%' => 4,
|
|
304
|
+ '%count_favorited%' => 2,
|
|
305
|
+ '%count_favorited_users%' => 1
|
|
306
|
+ ), 'elements')
|
|
307
|
+ .'")');
|
|
308
|
+ $this->exist('p.show_info:contains("'.
|
|
309
|
+ $this->getContainer()->get('translator')->trans('show.user.followers.zero_count', array(
|
|
310
|
+ '%name%' => $paul->getName()
|
|
311
|
+ ), 'elements')
|
|
312
|
+ .'")');
|
|
313
|
+
|
|
314
|
+ // joelle va mette un de ces deux elements en favoris
|
|
315
|
+ $this->disconnectUser();
|
|
316
|
+ $this->connectUser('joelle', 'toor');
|
|
317
|
+
|
|
318
|
+ // joelle met en favoris un de ces élément
|
122
|
319
|
$element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
123
|
|
- ->findOneByName('PsyElement 1')
|
|
320
|
+ ->findOneByName('CardioT3K - Juggernaut Trap')
|
124
|
321
|
;
|
125
|
|
- $tags = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')
|
126
|
|
- ->getElementsTags($fan_de_psy->getId(), $bux->getId())
|
|
322
|
+
|
|
323
|
+ $url = $this->generateUrl('favorite_add', array(
|
|
324
|
+ 'id' => $element->getId(),
|
|
325
|
+ 'token' => $joelle->getPersonalHash()
|
|
326
|
+ ));
|
|
327
|
+
|
|
328
|
+ $crawler = $this->client->request('GET', $url, array(), array(), array(
|
|
329
|
+ 'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
|
330
|
+ ));
|
|
331
|
+
|
|
332
|
+ $this->isResponseSuccess();
|
|
333
|
+
|
|
334
|
+ // On contrôle la présence du favoris
|
|
335
|
+ $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
|
|
336
|
+ ->findOneBy(array(
|
|
337
|
+ 'user' => $joelle->getId(),
|
|
338
|
+ 'element' => $element->getId()
|
|
339
|
+ ));
|
|
340
|
+
|
|
341
|
+ $this->assertTrue(!is_null($fav));
|
|
342
|
+
|
|
343
|
+ // On rafraichie la page
|
|
344
|
+ $this->crawler = $this->client->request('GET',
|
|
345
|
+ $this->generateUrl('show_user', array('slug' => $paul->getSlug()))
|
|
346
|
+ );
|
|
347
|
+ $this->isResponseSuccess();
|
|
348
|
+
|
|
349
|
+ // D'après les fixtures
|
|
350
|
+ $this->exist('p.show_info:contains("'.
|
|
351
|
+ $this->getContainer()->get('translator')->trans('show.user.elements.count', array(
|
|
352
|
+ '%count_owned%' => 4,
|
|
353
|
+ '%count_favorited%' => 2,
|
|
354
|
+ '%count_favorited_users%' => 2
|
|
355
|
+ ), 'elements')
|
|
356
|
+ .'")');
|
|
357
|
+ $this->exist('p.show_info:contains("'.
|
|
358
|
+ $this->getContainer()->get('translator')->trans('show.user.followers.zero_count', array(
|
|
359
|
+ '%name%' => $paul->getName()
|
|
360
|
+ ), 'elements')
|
|
361
|
+ .'")');
|
|
362
|
+
|
|
363
|
+ // joelle met en favoris un autre élément
|
|
364
|
+ $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
|
|
365
|
+ ->findOneByName('RE-FUCK (ReVeRB_FBC) mix.')
|
127
|
366
|
;
|
128
|
367
|
|
129
|
|
- $ids = array();
|
130
|
|
- foreach ($tags as $tag)
|
131
|
|
- {
|
132
|
|
- $ids[] = $tag->getId();
|
133
|
|
- }
|
134
|
|
-
|
135
|
|
- // On fait la demande pour en voir plus
|
136
|
|
- $url = $this->generateUrl('show_elements_get', array(
|
137
|
|
- 'type' => 'group',
|
138
|
|
- 'object_id' => $fan_de_psy->getId(),
|
139
|
|
- 'tags_ids_json' => json_encode($ids),
|
140
|
|
- 'id_limit' => $element->getId()
|
|
368
|
+ $url = $this->generateUrl('favorite_add', array(
|
|
369
|
+ 'id' => $element->getId(),
|
|
370
|
+ 'token' => $joelle->getPersonalHash()
|
141
|
371
|
));
|
142
|
|
- $crawler = $this->client->request(
|
143
|
|
- 'GET',
|
144
|
|
- $url,
|
145
|
|
- array(),
|
146
|
|
- array(),
|
147
|
|
- array('HTTP_X-Requested-With' => 'XMLHttpRequest')
|
|
372
|
+
|
|
373
|
+ $crawler = $this->client->request('GET', $url, array(), array(), array(
|
|
374
|
+ 'HTTP_X-Requested-With' => 'XMLHttpRequest',
|
|
375
|
+ ));
|
|
376
|
+
|
|
377
|
+ $this->isResponseSuccess();
|
|
378
|
+
|
|
379
|
+ // On contrôle la présence du favoris
|
|
380
|
+ $fav = $this->getDoctrine()->getRepository('MuzichCoreBundle:UsersElementsFavorites')
|
|
381
|
+ ->findOneBy(array(
|
|
382
|
+ 'user' => $joelle->getId(),
|
|
383
|
+ 'element' => $element->getId()
|
|
384
|
+ ));
|
|
385
|
+
|
|
386
|
+ $this->assertTrue(!is_null($fav));
|
|
387
|
+
|
|
388
|
+ // On rafraichie la page
|
|
389
|
+ $this->crawler = $this->client->request('GET',
|
|
390
|
+ $this->generateUrl('show_user', array('slug' => $paul->getSlug()))
|
148
|
391
|
);
|
|
392
|
+ $this->isResponseSuccess();
|
149
|
393
|
|
150
|
|
- $response = json_decode($this->client->getResponse()->getContent(), true);
|
151
|
|
- $this->assertEquals($response['status'], 'success');
|
152
|
|
- $this->assertTrue(strpos($response['html'], 'Infected mushroom - Muse Breaks') !== false);
|
153
|
|
- $this->assertTrue(strpos($response['html'], 'Infected Mushroom - Psycho') !== false);
|
|
394
|
+ // D'après les fixtures
|
|
395
|
+ $this->exist('p.show_info:contains("'.
|
|
396
|
+ $this->getContainer()->get('translator')->trans('show.user.elements.count', array(
|
|
397
|
+ '%count_owned%' => 4,
|
|
398
|
+ '%count_favorited%' => 3,
|
|
399
|
+ '%count_favorited_users%' => 2
|
|
400
|
+ ), 'elements')
|
|
401
|
+ .'")');
|
|
402
|
+ $this->exist('p.show_info:contains("'.
|
|
403
|
+ $this->getContainer()->get('translator')->trans('show.user.followers.zero_count', array(
|
|
404
|
+ '%name%' => $paul->getName()
|
|
405
|
+ ), 'elements')
|
|
406
|
+ .'")');
|
154
|
407
|
}
|
155
|
408
|
|
156
|
409
|
}
|