diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-01-12 19:33:00 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-01-12 19:33:00 +0100 |
commit | fcc3b3d5f70eb44787a70dd17b5a843729b1f0d8 (patch) | |
tree | defc94c8fe75bdc7219b32f70d180a1ddc21f47f /tests | |
parent | 331d73c3a37e74f1e322b9bfb239940275422a65 (diff) | |
download | nextcloud-server-fcc3b3d5f70eb44787a70dd17b5a843729b1f0d8.tar.gz nextcloud-server-fcc3b3d5f70eb44787a70dd17b5a843729b1f0d8.zip |
Fix searchCommon to properly match path name
The internal path was matched without the last "/" which caused
"files_trashbin" to also match when the internal path was "files".
This adds the missing slash for the comparison.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/files/node/folder.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php index bcd9cc93b5e..54b26ebdfe1 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 testSearchInRoot() { + $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('getUser', 'getMountsIn'), 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' => 'files/foo', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'), + array('fileid' => 3, 'path' => 'files_trashbin/foo2.d12345', 'name' => 'foo2.d12345', 'size' => 200, 'mtime' => 55, 'mimetype' => 'text/plain'), + ))); + + $root->expects($this->once()) + ->method('getMountsIn') + ->with('') + ->will($this->returnValue(array())); + + $view->expects($this->once()) + ->method('resolvePath') + ->will($this->returnValue(array($storage, 'files'))); + + $result = $root->search('qw'); + $this->assertEquals(1, count($result)); + $this->assertEquals('/foo', $result[0]->getPath()); + } + public function testSearchByTag() { $manager = $this->getMock('\OC\Files\Mount\Manager'); /** |