|
@@ -4,6 +4,7 @@ namespace Muzich\CoreBundle\Tests\Searcher;
|
4
|
4
|
|
5
|
5
|
use Muzich\CoreBundle\lib\UnitTest;
|
6
|
6
|
use Muzich\CoreBundle\Util\TagLike;
|
|
7
|
+use Muzich\CoreBundle\lib\Tag as TagLib;
|
7
|
8
|
|
8
|
9
|
class TagReadTest extends UnitTest
|
9
|
10
|
{
|
|
@@ -210,4 +211,93 @@ class TagReadTest extends UnitTest
|
210
|
211
|
$this->assertEquals($rtags, $tags);
|
211
|
212
|
}
|
212
|
213
|
|
|
214
|
+ /*
|
|
215
|
+ * Test des opération de création d'une liste ordonné de tags en fonction
|
|
216
|
+ * d'une liste d'élèments
|
|
217
|
+ */
|
|
218
|
+ public function testTagOrder()
|
|
219
|
+ {
|
|
220
|
+ $bux = $this->getUser('bux');
|
|
221
|
+ $joelle = $this->getUser('joelle');
|
|
222
|
+ $tag_lib = new TagLib();
|
|
223
|
+
|
|
224
|
+ $hardtek = $this->findOneBy('Tag', array('name' => 'Hardtek'));
|
|
225
|
+ $metal = $this->findOneBy('Tag', array('name' => 'Metal'));
|
|
226
|
+ $electro = $this->findOneBy('Tag', array('name' => 'Electro'));
|
|
227
|
+ $hardcore = $this->findOneBy('Tag', array('name' => 'Hardcore'));
|
|
228
|
+ $chanteuse = $this->findOneBy('Tag', array('name' => 'Chanteuse'));
|
|
229
|
+ $dubstep = $this->findOneBy('Tag', array('name' => 'Dubstep'));
|
|
230
|
+ $medieval = $this->findOneBy('Tag', array('name' => 'Medieval'));
|
|
231
|
+ $beatbox = $this->findOneBy('Tag', array('name' => 'Beatbox'));
|
|
232
|
+
|
|
233
|
+ /*
|
|
234
|
+ * Test de la récuparéation de l'ordre des tags
|
|
235
|
+ */
|
|
236
|
+
|
|
237
|
+ $search = new \Muzich\CoreBundle\Searcher\ElementSearcher();
|
|
238
|
+ $search->init(array(
|
|
239
|
+ 'user_id' => $bux->getId()
|
|
240
|
+ ));
|
|
241
|
+ $elements = $search->getElements($this->getDoctrine(), $bux->getId());
|
|
242
|
+
|
|
243
|
+ $tag_reference = $tag_lib->getOrderedTagsWithElements($elements);
|
|
244
|
+
|
|
245
|
+ $this->assertEquals(array(
|
|
246
|
+ $hardtek->getId(),
|
|
247
|
+ $metal->getId(),
|
|
248
|
+ $electro->getId(),
|
|
249
|
+ $hardcore->getId()
|
|
250
|
+ ), $tag_reference);
|
|
251
|
+
|
|
252
|
+ ////////////
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+ $search = new \Muzich\CoreBundle\Searcher\ElementSearcher();
|
|
256
|
+ $search->init(array(
|
|
257
|
+ 'user_id' => $joelle->getId()
|
|
258
|
+ ));
|
|
259
|
+ $elements = $search->getElements($this->getDoctrine(), $bux->getId());
|
|
260
|
+
|
|
261
|
+ $tag_reference = $tag_lib->getOrderedTagsWithElements($elements);
|
|
262
|
+
|
|
263
|
+ $this->assertEquals(array(
|
|
264
|
+ $chanteuse->getId(),
|
|
265
|
+ $dubstep->getId(),
|
|
266
|
+ $medieval->getId(),
|
|
267
|
+ $beatbox->getId()
|
|
268
|
+ ), $tag_reference);
|
|
269
|
+
|
|
270
|
+ /*
|
|
271
|
+ * Test du trie de tags en fonction d'une liste référente
|
|
272
|
+ */
|
|
273
|
+
|
|
274
|
+ // Tag non ordonés
|
|
275
|
+ $tags_disordered = array(
|
|
276
|
+ $medieval,
|
|
277
|
+ $beatbox,
|
|
278
|
+ $hardcore,
|
|
279
|
+ $dubstep,
|
|
280
|
+ $chanteuse
|
|
281
|
+ );
|
|
282
|
+
|
|
283
|
+ // On ordonne tout ça avec la référence calculé juste avant
|
|
284
|
+ $tags_ordered = $tag_lib->sortTagWithOrderedReference($tags_disordered, $tag_reference);
|
|
285
|
+
|
|
286
|
+ $tags_ordered_ids = array();
|
|
287
|
+ foreach ($tags_ordered as $tag_ordered)
|
|
288
|
+ {
|
|
289
|
+ $tags_ordered_ids[] = $tag_ordered->getId();
|
|
290
|
+ }
|
|
291
|
+
|
|
292
|
+ $this->assertEquals(
|
|
293
|
+ array(
|
|
294
|
+ $chanteuse->getId(),
|
|
295
|
+ $dubstep->getId(),
|
|
296
|
+ $medieval->getId(),
|
|
297
|
+ $beatbox->getId(),
|
|
298
|
+ $hardcore->getId()
|
|
299
|
+ ), $tags_ordered_ids
|
|
300
|
+ );
|
|
301
|
+ }
|
|
302
|
+
|
213
|
303
|
}
|