aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-12-12 14:27:19 +0100
committerVincent Petry <pvince81@owncloud.com>2014-12-12 14:27:19 +0100
commit4b57892c4eeeb7bd3c8b1b0465acf032dc84fd19 (patch)
treefbad2095651334fc34b3729ae5102ad5e1cd866f /apps/files_sharing/tests
parent6b4502adebf1d756707e8fb5b8ab697c1c746e6b (diff)
parent3878c3782ff37dc56a4e463acea351a61ed7b4c2 (diff)
downloadnextcloud-server-4b57892c4eeeb7bd3c8b1b0465acf032dc84fd19.tar.gz
nextcloud-server-4b57892c4eeeb7bd3c8b1b0465acf032dc84fd19.zip
Merge pull request #12778 from owncloud/searchbytags2
Added searchByTags to view, storage and cache
Diffstat (limited to 'apps/files_sharing/tests')
-rw-r--r--apps/files_sharing/tests/cache.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/apps/files_sharing/tests/cache.php b/apps/files_sharing/tests/cache.php
index aec1983bad3..b60bba73db8 100644
--- a/apps/files_sharing/tests/cache.php
+++ b/apps/files_sharing/tests/cache.php
@@ -204,6 +204,40 @@ class Test_Files_Sharing_Cache extends TestCase {
$this->verifyFiles($check, $results);
}
+ /**
+ * Test searching by tag
+ */
+ function testSearchByTag() {
+ $userId = \OC::$server->getUserSession()->getUser()->getUId();
+ $id1 = $this->sharedCache->get('bar.txt')['fileid'];
+ $id2 = $this->sharedCache->get('subdir/another too.txt')['fileid'];
+ $id3 = $this->sharedCache->get('subdir/not a text file.xml')['fileid'];
+ $id4 = $this->sharedCache->get('subdir/another.txt')['fileid'];
+ $tagManager = \OC::$server->getTagManager()->load('files', null, null, $userId);
+ $tagManager->tagAs($id1, 'tag1');
+ $tagManager->tagAs($id1, 'tag2');
+ $tagManager->tagAs($id2, 'tag1');
+ $tagManager->tagAs($id3, 'tag1');
+ $tagManager->tagAs($id4, 'tag2');
+ $results = $this->sharedStorage->getCache()->searchByTag('tag1', $userId);
+ $check = array(
+ array(
+ 'name' => 'bar.txt',
+ 'path' => 'bar.txt'
+ ),
+ array(
+ 'name' => 'another too.txt',
+ 'path' => 'subdir/another too.txt'
+ ),
+ array(
+ 'name' => 'not a text file.xml',
+ 'path' => 'subdir/not a text file.xml'
+ ),
+ );
+ $this->verifyFiles($check, $results);
+ $tagManager->delete(array('tag1', 'tag2'));
+ }
+
function testGetFolderContentsInRoot() {
$results = $this->user2View->getDirectoryContent('/');