@@ -328,76 +328,6 @@ function testSearch() {
328328 $ this ->assertEquals (2 , count ($ this ->cache ->searchByMime ('foo/file ' )));
329329 }
330330
331- function testSearchByTag () {
332- $ userId = $ this ->getUniqueId ('user ' );
333- \OC ::$ server ->getUserManager ()->createUser ($ userId , $ userId );
334- $ this ->loginAsUser ($ userId );
335- $ user = new \OC \User \User ($ userId , null , \OC ::$ server ->getEventDispatcher ());
336-
337- $ file1 = 'folder ' ;
338- $ file2 = 'folder/foobar ' ;
339- $ file3 = 'folder/foo ' ;
340- $ file4 = 'folder/foo2 ' ;
341- $ file5 = 'folder/foo3 ' ;
342- $ data1 = array ('size ' => 100 , 'mtime ' => 50 , 'mimetype ' => 'foo/folder ' );
343- $ fileData = array ();
344- $ fileData ['foobar ' ] = array ('size ' => 1000 , 'mtime ' => 20 , 'mimetype ' => 'foo/file ' );
345- $ fileData ['foo ' ] = array ('size ' => 20 , 'mtime ' => 25 , 'mimetype ' => 'foo/file ' );
346- $ fileData ['foo2 ' ] = array ('size ' => 25 , 'mtime ' => 28 , 'mimetype ' => 'foo/file ' );
347- $ fileData ['foo3 ' ] = array ('size ' => 88 , 'mtime ' => 34 , 'mimetype ' => 'foo/file ' );
348-
349- $ id1 = $ this ->cache ->put ($ file1 , $ data1 );
350- $ id2 = $ this ->cache ->put ($ file2 , $ fileData ['foobar ' ]);
351- $ id3 = $ this ->cache ->put ($ file3 , $ fileData ['foo ' ]);
352- $ id4 = $ this ->cache ->put ($ file4 , $ fileData ['foo2 ' ]);
353- $ id5 = $ this ->cache ->put ($ file5 , $ fileData ['foo3 ' ]);
354-
355- $ tagManager = \OC ::$ server ->getTagManager ()->load ('files ' , [], false , $ userId );
356- $ this ->assertTrue ($ tagManager ->tagAs ($ id1 , 'tag1 ' ));
357- $ this ->assertTrue ($ tagManager ->tagAs ($ id1 , 'tag2 ' ));
358- $ this ->assertTrue ($ tagManager ->tagAs ($ id2 , 'tag2 ' ));
359- $ this ->assertTrue ($ tagManager ->tagAs ($ id3 , 'tag1 ' ));
360- $ this ->assertTrue ($ tagManager ->tagAs ($ id4 , 'tag2 ' ));
361-
362- // use tag name
363- $ results = $ this ->cache ->searchByTag ('tag1 ' , $ userId );
364-
365- $ this ->assertEquals (2 , count ($ results ));
366-
367- usort ($ results , function ($ value1 , $ value2 ) {
368- return $ value1 ['name ' ] >= $ value2 ['name ' ];
369- });
370-
371- $ this ->assertEquals ('folder ' , $ results [0 ]['name ' ]);
372- $ this ->assertEquals ('foo ' , $ results [1 ]['name ' ]);
373-
374- // use tag id
375- $ tags = $ tagManager ->getTagsForUser ($ userId );
376- $ this ->assertNotEmpty ($ tags );
377- $ tags = array_filter ($ tags , function ($ tag ) {
378- return $ tag ->getName () === 'tag2 ' ;
379- });
380- $ results = $ this ->cache ->searchByTag (current ($ tags )->getId (), $ userId );
381- $ this ->assertEquals (3 , count ($ results ));
382-
383- usort ($ results , function ($ value1 , $ value2 ) {
384- return $ value1 ['name ' ] >= $ value2 ['name ' ];
385- });
386-
387- $ this ->assertEquals ('folder ' , $ results [0 ]['name ' ]);
388- $ this ->assertEquals ('foo2 ' , $ results [1 ]['name ' ]);
389- $ this ->assertEquals ('foobar ' , $ results [2 ]['name ' ]);
390-
391- $ tagManager ->delete ('tag1 ' );
392- $ tagManager ->delete ('tag2 ' );
393-
394- $ this ->logout ();
395- $ user = \OC ::$ server ->getUserManager ()->get ($ userId );
396- if ($ user !== null ) {
397- $ user ->delete ();
398- }
399- }
400-
401331 function testSearchQueryByTag () {
402332 $ userId = static ::getUniqueID ('user ' );
403333 \OC ::$ server ->getUserManager ()->createUser ($ userId , $ userId );
0 commit comments