|
@@ -45,154 +45,280 @@ class ElementSearcherTest extends UnitTest
|
45
|
45
|
$this->assertEquals($ua, $es->getParams());
|
46
|
46
|
}
|
47
|
47
|
|
48
|
|
- public function testGetElements()
|
|
48
|
+ protected function checkElementSearchResults($es_results, $array_names)
|
|
49
|
+ {
|
|
50
|
+ $cpt = 0;
|
|
51
|
+ $array_names_es = array();
|
|
52
|
+ foreach ($es_results as $element)
|
|
53
|
+ {
|
|
54
|
+ $array_names_es[] = $element->getName();
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+ $this->assertEquals($array_names, $array_names_es);
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+ * Test pour la configuration:
|
|
62
|
+ * public
|
|
63
|
+ * tags
|
|
64
|
+ * limit
|
|
65
|
+ *
|
|
66
|
+ * Test basés sur les FIXTURES
|
|
67
|
+ */
|
|
68
|
+ public function testGetPublicForTags()
|
49
|
69
|
{
|
50
|
70
|
$r = $this->getDoctrine();
|
51
|
71
|
$bux = $r->getRepository('MuzichCoreBundle:User')
|
52
|
72
|
->findOneByUsername('bux')
|
53
|
73
|
;
|
|
74
|
+ $hardtek = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
75
|
+ $tribe = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
76
|
+ $electro = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Electro');
|
54
|
77
|
|
55
|
|
-
|
56
|
|
- * Première passe: On check que la recherche nous retourne bien les
|
57
|
|
- * elements de jean
|
58
|
|
- */
|
59
|
|
- $jean = $r->getRepository('MuzichCoreBundle:User')
|
60
|
|
- ->findOneByUsername('jean')
|
|
78
|
+ $es = new ElementSearcher();
|
|
79
|
+ $es->init(array(
|
|
80
|
+ 'network' => ElementSearcher::NETWORK_PUBLIC,
|
|
81
|
+ 'tags' => array($hardtek->getId(), $tribe->getId(), $electro->getId()),
|
|
82
|
+ 'count' => 5
|
|
83
|
+ ));
|
|
84
|
+
|
|
85
|
+ $this->checkElementSearchResults(
|
|
86
|
+ $es->getElements($r, $bux->getId()),
|
|
87
|
+ array(
|
|
88
|
+ 'Ed Cox - La fanfare des teuffeurs (Hardcordian)',
|
|
89
|
+ 'CardioT3K - Juggernaut Trap',
|
|
90
|
+ 'Acrotek Hardtek G01',
|
|
91
|
+ 'KoinkOin - H5N1',
|
|
92
|
+ 'Antropod - Polakatek'
|
|
93
|
+ )
|
|
94
|
+ );
|
|
95
|
+
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+ * Test pour la configuration:
|
|
100
|
+ * personal
|
|
101
|
+ * tags
|
|
102
|
+ * limit
|
|
103
|
+ *
|
|
104
|
+ * Test basés sur les FIXTURES
|
|
105
|
+ */
|
|
106
|
+ public function testGetPersonalForTags()
|
|
107
|
+ {
|
|
108
|
+ $r = $this->getDoctrine();
|
|
109
|
+ $bux = $r->getRepository('MuzichCoreBundle:User')
|
|
110
|
+ ->findOneByUsername('bux')
|
61
|
111
|
;
|
|
112
|
+ $hardtek = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
|
113
|
+ $tribe = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
114
|
+ $electro = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Electro');
|
|
115
|
+
|
62
|
116
|
$es = new ElementSearcher();
|
63
|
117
|
$es->init(array(
|
64
|
|
- 'user_id' => $jean->getId(),
|
65
|
|
- 'count' => 20
|
|
118
|
+ 'network' => ElementSearcher::NETWORK_PERSONAL,
|
|
119
|
+ 'tags' => array($hardtek->getId(), $tribe->getId(), $electro->getId()),
|
|
120
|
+ 'count' => 5
|
|
121
|
+ ));
|
|
122
|
+
|
|
123
|
+ $this->checkElementSearchResults(
|
|
124
|
+ $es->getElements($r, $bux->getId()),
|
|
125
|
+ array(
|
|
126
|
+ 'CardioT3K - Juggernaut Trap',
|
|
127
|
+ 'Acrotek Hardtek G01',
|
|
128
|
+ 'RE-FUCK (ReVeRB_FBC) mix.',
|
|
129
|
+ 'All Is Full Of Pain',
|
|
130
|
+ 'Dj antoine'
|
|
131
|
+ )
|
|
132
|
+ );
|
|
133
|
+
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+ * Test pour la configuration:
|
|
138
|
+ * public
|
|
139
|
+ * limit
|
|
140
|
+ *
|
|
141
|
+ * Test basés sur les FIXTURES
|
|
142
|
+ */
|
|
143
|
+ public function testGetPublicWithoutTags()
|
|
144
|
+ {
|
|
145
|
+ $r = $this->getDoctrine();
|
|
146
|
+ $bux = $r->getRepository('MuzichCoreBundle:User')
|
|
147
|
+ ->findOneByUsername('bux')
|
|
148
|
+ ;
|
|
149
|
+
|
|
150
|
+ $es = new ElementSearcher();
|
|
151
|
+ $es->init(array(
|
|
152
|
+ 'network' => ElementSearcher::NETWORK_PUBLIC,
|
|
153
|
+ 'count' => 5
|
66
|
154
|
));
|
67
|
155
|
|
68
|
|
-
|
69
|
|
-
|
70
|
|
- $query_results = $r->getEntityManager()
|
71
|
|
- ->createQuery("SELECT e
|
72
|
|
- FROM MuzichCoreBundle:Element e
|
73
|
|
- WHERE e.owner = :suid
|
74
|
|
- ORDER BY e.created DESC, e.id DESC")
|
75
|
|
- ->setParameter('suid', $jean->getId())
|
76
|
|
- ->setMaxResults(20)
|
77
|
|
- ->getResult()
|
|
156
|
+ $this->checkElementSearchResults(
|
|
157
|
+ $es->getElements($r, $bux->getId()),
|
|
158
|
+ array(
|
|
159
|
+ 'DUDELDRUM',
|
|
160
|
+ 'Ed Cox - La fanfare des teuffeurs (Hardcordian)',
|
|
161
|
+ 'Babylon Pression - Des Tasers et des Pauvres',
|
|
162
|
+ 'SOULFLY - Prophecy',
|
|
163
|
+ 'CardioT3K - Juggernaut Trap'
|
|
164
|
+ )
|
|
165
|
+ );
|
|
166
|
+
|
|
167
|
+ }
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+ * Test pour la configuration:
|
|
171
|
+ * personal
|
|
172
|
+ * limit
|
|
173
|
+ *
|
|
174
|
+ * Test basés sur les FIXTURES
|
|
175
|
+ */
|
|
176
|
+ public function testGetPersonalWithoutTags()
|
|
177
|
+ {
|
|
178
|
+ $r = $this->getDoctrine();
|
|
179
|
+ $bux = $r->getRepository('MuzichCoreBundle:User')
|
|
180
|
+ ->findOneByUsername('bux')
|
78
|
181
|
;
|
79
|
182
|
|
80
|
|
-
|
81
|
|
- $searcher_results = $es->getElements($r, $bux->getId());
|
|
183
|
+ $es = new ElementSearcher();
|
|
184
|
+ $es->init(array(
|
|
185
|
+ 'network' => ElementSearcher::NETWORK_PERSONAL,
|
|
186
|
+ 'count' => 5
|
|
187
|
+ ));
|
|
188
|
+
|
|
189
|
+ $this->checkElementSearchResults(
|
|
190
|
+ $es->getElements($r, $bux->getId()),
|
|
191
|
+ array(
|
|
192
|
+ 'DUDELDRUM',
|
|
193
|
+ 'CardioT3K - Juggernaut Trap',
|
|
194
|
+ 'Acrotek Hardtek G01',
|
|
195
|
+ 'Infected Mushroom - Psycho',
|
|
196
|
+ 'Infected mushroom - Muse Breaks'
|
|
197
|
+ )
|
|
198
|
+ );
|
82
|
199
|
|
83
|
|
-
|
84
|
|
- $this->assertEquals($query_results, $searcher_results);
|
|
200
|
+ }
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+ * Test pour la configuration:
|
|
204
|
+ * personal
|
|
205
|
+ * limit
|
|
206
|
+ *
|
|
207
|
+ * Test basés sur les FIXTURES
|
|
208
|
+ */
|
|
209
|
+ public function testGetProfile()
|
|
210
|
+ {
|
|
211
|
+ $r = $this->getDoctrine();
|
|
212
|
+ $bux = $r->getRepository('MuzichCoreBundle:User')
|
|
213
|
+ ->findOneByUsername('bux')
|
|
214
|
+ ;
|
|
215
|
+ $jean = $r->getRepository('MuzichCoreBundle:User')
|
|
216
|
+ ->findOneByUsername('jean')
|
|
217
|
+ ;
|
85
|
218
|
|
86
|
|
-
|
87
|
|
- * Contrôle de sortie des favoris d'un user (paul)
|
88
|
|
- */
|
|
219
|
+ $es = new ElementSearcher();
|
|
220
|
+ $es->init(array(
|
|
221
|
+ 'user_id' => $jean->getId(),
|
|
222
|
+ 'count' => 5
|
|
223
|
+ ));
|
|
224
|
+
|
|
225
|
+ $this->checkElementSearchResults(
|
|
226
|
+ $es->getElements($r, $bux->getId()),
|
|
227
|
+ array(
|
|
228
|
+ 'Acrotek Hardtek G01',
|
|
229
|
+ 'Dj antoine',
|
|
230
|
+ 'DJ FAB'
|
|
231
|
+ )
|
|
232
|
+ );
|
89
|
233
|
|
90
|
234
|
$paul = $r->getRepository('MuzichCoreBundle:User')
|
91
|
235
|
->findOneByUsername('paul')
|
92
|
236
|
;
|
|
237
|
+
|
93
|
238
|
$es = new ElementSearcher();
|
94
|
239
|
$es->init(array(
|
95
|
240
|
'user_id' => $paul->getId(),
|
96
|
|
- 'favorite' => true,
|
97
|
|
- 'count' => 20
|
|
241
|
+ 'count' => 5
|
98
|
242
|
));
|
99
|
243
|
|
100
|
|
- $query_results = $r->getEntityManager()
|
101
|
|
- ->createQuery("SELECT e
|
102
|
|
- FROM MuzichCoreBundle:Element e
|
103
|
|
- JOIN e.elements_favorites fav2
|
104
|
|
- WHERE fav2.user = :fuid
|
105
|
|
- ORDER BY e.created DESC, e.id DESC")
|
106
|
|
- ->setParameter('fuid', $paul->getId())
|
107
|
|
- ->setMaxResults(20)
|
108
|
|
- ->getResult()
|
|
244
|
+ $this->checkElementSearchResults(
|
|
245
|
+ $es->getElements($r, $bux->getId()),
|
|
246
|
+ array(
|
|
247
|
+ 'CardioT3K - Juggernaut Trap',
|
|
248
|
+ 'Infected Mushroom - Psycho',
|
|
249
|
+ 'RE-FUCK (ReVeRB_FBC) mix.',
|
|
250
|
+ 'All Is Full Of Pain'
|
|
251
|
+ )
|
|
252
|
+ );
|
|
253
|
+
|
|
254
|
+ }
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+ * Test pour la configuration:
|
|
258
|
+ * personal
|
|
259
|
+ * limit
|
|
260
|
+ *
|
|
261
|
+ * Test basés sur les FIXTURES
|
|
262
|
+ */
|
|
263
|
+ public function testGetFavoriteProfile()
|
|
264
|
+ {
|
|
265
|
+ $r = $this->getDoctrine();
|
|
266
|
+ $bux = $r->getRepository('MuzichCoreBundle:User')
|
|
267
|
+ ->findOneByUsername('bux')
|
109
|
268
|
;
|
110
|
269
|
|
111
|
|
-
|
112
|
|
- $searcher_results = $es->getElements($r, $paul->getId());
|
|
270
|
+ $paul = $r->getRepository('MuzichCoreBundle:User')
|
|
271
|
+ ->findOneByUsername('paul')
|
|
272
|
+ ;
|
113
|
273
|
|
114
|
|
-
|
115
|
|
- $this->assertEquals($query_results, $searcher_results);
|
|
274
|
+ $es = new ElementSearcher();
|
|
275
|
+ $es->init(array(
|
|
276
|
+ 'user_id' => $paul->getId(),
|
|
277
|
+ 'favorite' => true,
|
|
278
|
+ 'count' => 5
|
|
279
|
+ ));
|
116
|
280
|
|
117
|
|
-
|
118
|
|
- * Contrôle de sortie d'un affichage public, avec tags
|
119
|
|
- */
|
|
281
|
+ $this->checkElementSearchResults(
|
|
282
|
+ $es->getElements($r, $bux->getId()),
|
|
283
|
+ array(
|
|
284
|
+ 'Heretik System Popof - Resistance',
|
|
285
|
+ 'All Is Full Of Pain'
|
|
286
|
+ )
|
|
287
|
+ );
|
120
|
288
|
|
121
|
|
- $hardtek = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
|
122
|
|
- $tribe = $r->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
|
|
289
|
+ }
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+ * Test pour la configuration:
|
|
293
|
+ * personal
|
|
294
|
+ * limit
|
|
295
|
+ *
|
|
296
|
+ * Test basés sur les FIXTURES
|
|
297
|
+ */
|
|
298
|
+ public function testGetGroup()
|
|
299
|
+ {
|
|
300
|
+ $r = $this->getDoctrine();
|
|
301
|
+ $bux = $r->getRepository('MuzichCoreBundle:User')
|
|
302
|
+ ->findOneByUsername('bux')
|
|
303
|
+ ;
|
|
304
|
+ $fdepsy = $r->getRepository('MuzichCoreBundle:Group')
|
|
305
|
+ ->findOneByName('Fans de psytrance')
|
|
306
|
+ ;
|
123
|
307
|
|
124
|
308
|
$es = new ElementSearcher();
|
125
|
309
|
$es->init(array(
|
126
|
|
- 'network' => ElementSearcher::NETWORK_PUBLIC,
|
127
|
|
- 'tags' => array(
|
128
|
|
- $hardtek->getId(),
|
129
|
|
- $tribe->getId()
|
130
|
|
- ),
|
131
|
|
- 'count' => 20
|
|
310
|
+ 'group_id' => $fdepsy->getId(),
|
|
311
|
+ 'count' => 5
|
132
|
312
|
));
|
133
|
|
-
|
134
|
|
- $query_results = $r->getEntityManager()
|
135
|
|
- ->createQuery("SELECT e
|
136
|
|
- FROM MuzichCoreBundle:Element e
|
137
|
|
- LEFT JOIN e.tags t
|
138
|
|
- WHERE (t.id = :tidHardtek OR t.id = :tidTribe)
|
139
|
|
- ORDER BY e.created DESC, e.id DESC")
|
140
|
|
- ->setParameters(array(
|
141
|
|
- 'tidHardtek' => $hardtek->getId(),
|
142
|
|
- 'tidTribe' => $tribe->getId()
|
143
|
|
- ))
|
144
|
|
- ->setMaxResults(20)
|
145
|
|
- ->getResult()
|
146
|
|
- ;
|
147
|
313
|
|
148
|
|
-
|
149
|
|
- $searcher_results = $es->getElements($r, $paul->getId());
|
150
|
|
-
|
151
|
|
-
|
152
|
|
- $this->assertEquals($query_results, $searcher_results);
|
153
|
|
-
|
154
|
|
-
|
155
|
|
-
|
156
|
|
-
|
157
|
|
-
|
158
|
|
-
|
159
|
|
-
|
160
|
|
-
|
161
|
|
-
|
162
|
|
-
|
163
|
|
-
|
164
|
|
-
|
165
|
|
-
|
166
|
|
-
|
167
|
|
-
|
168
|
|
-
|
169
|
|
-
|
170
|
|
-
|
171
|
|
-
|
172
|
|
-
|
173
|
|
-
|
174
|
|
-
|
175
|
|
-
|
176
|
|
-
|
177
|
|
-
|
178
|
|
-
|
179
|
|
-
|
180
|
|
-
|
181
|
|
-
|
182
|
|
-
|
183
|
|
-
|
184
|
|
-
|
185
|
|
-
|
186
|
|
-
|
187
|
|
-
|
188
|
|
-
|
189
|
|
-
|
190
|
|
-
|
191
|
|
-
|
192
|
|
-
|
193
|
|
-
|
194
|
|
-
|
195
|
|
-
|
196
|
|
-
|
|
314
|
+ $this->checkElementSearchResults(
|
|
315
|
+ $es->getElements($r, $bux->getId()),
|
|
316
|
+ array(
|
|
317
|
+ 'Infected Mushroom - Psycho',
|
|
318
|
+ 'Infected mushroom - Muse Breaks'
|
|
319
|
+ )
|
|
320
|
+ );
|
|
321
|
+
|
197
|
322
|
}
|
|
323
|
+
|
198
|
324
|
}
|