aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-12-12 11:18:35 +0100
committerVincent Petry <pvince81@owncloud.com>2014-12-12 11:18:35 +0100
commit15ecb28d50e5b8ce4100075caa52d96d4f00ae13 (patch)
tree02ca5b15c2a09afaa6a44a71fcf14d3c53184200 /tests
parent25dde7e93bc648ec8cd14b8f2711d50f77d8d1bf (diff)
downloadnextcloud-server-15ecb28d50e5b8ce4100075caa52d96d4f00ae13.tar.gz
nextcloud-server-15ecb28d50e5b8ce4100075caa52d96d4f00ae13.zip
Make $userId mandatory for searchByTags
$userId is now a mandatory parameter for searchByTags. Also fixed some places in the code where the argument was missing (Node API and View)
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/node/folder.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php
index d8c047a2b75..e69a2776979 100644
--- a/tests/lib/files/node/folder.php
+++ b/tests/lib/files/node/folder.php
@@ -405,6 +405,45 @@ class Folder extends \Test\TestCase {
$this->assertEquals('/bar/foo/qwerty', $result[0]->getPath());
}
+ public function testSearchByTag() {
+ $manager = $this->getMock('\OC\Files\Mount\Manager');
+ /**
+ * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
+ */
+ $view = $this->getMock('\OC\Files\View');
+ $root = $this->getMock('\OC\Files\Node\Root', array(), array($manager, $view, $this->user));
+ $root->expects($this->any())
+ ->method('getUser')
+ ->will($this->returnValue($this->user));
+ $storage = $this->getMock('\OC\Files\Storage\Storage');
+ $cache = $this->getMock('\OC\Files\Cache\Cache', array(), array(''));
+
+ $storage->expects($this->once())
+ ->method('getCache')
+ ->will($this->returnValue($cache));
+
+ $cache->expects($this->once())
+ ->method('searchByTag')
+ ->with('tag1', 'user1')
+ ->will($this->returnValue(array(
+ array('fileid' => 3, 'path' => 'foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain')
+ )));
+
+ $root->expects($this->once())
+ ->method('getMountsIn')
+ ->with('/bar/foo')
+ ->will($this->returnValue(array()));
+
+ $view->expects($this->once())
+ ->method('resolvePath')
+ ->will($this->returnValue(array($storage, 'foo')));
+
+ $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo');
+ $result = $node->searchByTag('tag1', 'user1');
+ $this->assertEquals(1, count($result));
+ $this->assertEquals('/bar/foo/qwerty', $result[0]->getPath());
+ }
+
public function testSearchSubStorages() {
$manager = $this->getMock('\OC\Files\Mount\Manager');
/**