summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-10-08 13:17:26 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-10-08 13:17:26 +0200
commit2fda4e38e21f1dc0fffdc17dfd2dce1ee67da243 (patch)
treeb35241a21230ca27c7dc9ab705fe087a8a074b26 /tests
parent8d2c8cf2a262d6299932125872fb0d536881a058 (diff)
parentc2d76d201075733a89d5167faf1091e589249a77 (diff)
downloadnextcloud-server-2fda4e38e21f1dc0fffdc17dfd2dce1ee67da243.tar.gz
nextcloud-server-2fda4e38e21f1dc0fffdc17dfd2dce1ee67da243.zip
Merge pull request #19546 from owncloud/fix-search-for-node-api
Fix search operations for the Node API
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 b30f352847d..8c98256575e 100644
--- a/tests/lib/files/node/folder.php
+++ b/tests/lib/files/node/folder.php
@@ -421,6 +421,45 @@ class Folder extends \Test\TestCase {
$this->assertEquals('/foo', $result[0]->getPath());
}
+ public function testSearchInStorageRoot() {
+ $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('search')
+ ->with('%qw%')
+ ->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')
+ ->will($this->returnValue(array()));
+
+ $view->expects($this->once())
+ ->method('resolvePath')
+ ->will($this->returnValue(array($storage, '')));
+
+ $node = new \OC\Files\Node\Folder($root, $view, '/bar');
+ $result = $node->search('qw');
+ $this->assertEquals(1, count($result));
+ $this->assertEquals('/bar/foo/qwerty', $result[0]->getPath());
+ }
+
public function testSearchByTag() {
$manager = $this->getMock('\OC\Files\Mount\Manager');
/**