diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-09-12 17:09:46 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-10-19 11:06:29 +0200 |
commit | 361f008c705009eee8d7435f46095760ac706456 (patch) | |
tree | 95e7033befa4ff0fc20e60f5df2a4b249575d636 /apps/files/tests/Controller | |
parent | 5e48ce98c70fa511ea2c1caeb332594912c9d96a (diff) | |
download | nextcloud-server-361f008c705009eee8d7435f46095760ac706456.tar.gz nextcloud-server-361f008c705009eee8d7435f46095760ac706456.zip |
Make it possible to filter by tags with REPORT method
Enhanced the REPORT method on the Webdav endpoint and added a
"oc:favorite" filter rule. When set, it will return a flat list of
results filtered with only favorite files.
The web UI was also adjusted to use this REPORT method instead of the
private API endpoint.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files/tests/Controller')
-rw-r--r-- | apps/files/tests/Controller/ApiControllerTest.php | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php index 9bfc6d6f5e8..4b7bec065a0 100644 --- a/apps/files/tests/Controller/ApiControllerTest.php +++ b/apps/files/tests/Controller/ApiControllerTest.php @@ -103,182 +103,6 @@ class ApiControllerTest extends TestCase { ); } - public function testGetFilesByTagEmpty() { - $tagName = 'MyTagName'; - $this->tagService->expects($this->once()) - ->method('getFilesByTag') - ->with($this->equalTo([$tagName])) - ->will($this->returnValue([])); - - $expected = new DataResponse(['files' => []]); - $this->assertEquals($expected, $this->apiController->getFilesByTag([$tagName])); - } - - public function testGetFilesByTagSingle() { - $tagName = 'MyTagName'; - $fileInfo = new FileInfo( - '/root.txt', - $this->getMockBuilder('\OC\Files\Storage\Storage') - ->disableOriginalConstructor() - ->getMock(), - '/var/www/root.txt', - [ - 'mtime' => 55, - 'mimetype' => 'application/pdf', - 'permissions' => 31, - 'size' => 1234, - 'etag' => 'MyEtag', - ], - $this->getMockBuilder('\OCP\Files\Mount\IMountPoint') - ->disableOriginalConstructor() - ->getMock() - ); - $node = $this->getMockBuilder('\OC\Files\Node\File') - ->disableOriginalConstructor() - ->getMock(); - $node->expects($this->once()) - ->method('getFileInfo') - ->will($this->returnValue($fileInfo)); - $this->tagService->expects($this->once()) - ->method('getFilesByTag') - ->with($this->equalTo([$tagName])) - ->will($this->returnValue([$node])); - - $this->shareManager->expects($this->any()) - ->method('getSharesBy') - ->with( - $this->equalTo('user1'), - $this->anything(), - $node, - $this->equalTo(false), - $this->equalTo(1) - ) - ->will($this->returnCallback(function($userId, $shareType) { - if ($shareType === \OCP\Share::SHARE_TYPE_USER || $shareType === \OCP\Share::SHARE_TYPE_LINK) { - return ['dummy_share']; - } - return []; - })); - - $expected = new DataResponse([ - 'files' => [ - [ - 'id' => null, - 'parentId' => null, - 'mtime' => 55000, - 'name' => 'root.txt', - 'permissions' => 31, - 'mimetype' => 'application/pdf', - 'size' => 1234, - 'type' => 'file', - 'etag' => 'MyEtag', - 'path' => '/', - 'tags' => [ - [ - 'MyTagName' - ] - ], - 'shareTypes' => [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK] - ], - ], - ]); - $this->assertEquals($expected, $this->apiController->getFilesByTag([$tagName])); - } - - public function testGetFilesByTagMultiple() { - $tagName = 'MyTagName'; - $fileInfo1 = new FileInfo( - '/root.txt', - $this->getMockBuilder('\OC\Files\Storage\Storage') - ->disableOriginalConstructor() - ->getMock(), - '/var/www/root.txt', - [ - 'mtime' => 55, - 'mimetype' => 'application/pdf', - 'permissions' => 31, - 'size' => 1234, - 'etag' => 'MyEtag', - ], - $this->getMockBuilder('\OCP\Files\Mount\IMountPoint') - ->disableOriginalConstructor() - ->getMock() - ); - $fileInfo2 = new FileInfo( - '/root.txt', - $this->getMockBuilder('\OC\Files\Storage\Storage') - ->disableOriginalConstructor() - ->getMock(), - '/var/www/some/sub.txt', - [ - 'mtime' => 999, - 'mimetype' => 'application/binary', - 'permissions' => 31, - 'size' => 9876, - 'etag' => 'SubEtag', - ], - $this->getMockBuilder('\OCP\Files\Mount\IMountPoint') - ->disableOriginalConstructor() - ->getMock() - ); - $node1 = $this->getMockBuilder('\OC\Files\Node\File') - ->disableOriginalConstructor() - ->getMock(); - $node1->expects($this->once()) - ->method('getFileInfo') - ->will($this->returnValue($fileInfo1)); - $node2 = $this->getMockBuilder('\OC\Files\Node\File') - ->disableOriginalConstructor() - ->getMock(); - $node2->expects($this->once()) - ->method('getFileInfo') - ->will($this->returnValue($fileInfo2)); - $this->tagService->expects($this->once()) - ->method('getFilesByTag') - ->with($this->equalTo([$tagName])) - ->will($this->returnValue([$node1, $node2])); - - $expected = new DataResponse([ - 'files' => [ - [ - 'id' => null, - 'parentId' => null, - 'mtime' => 55000, - 'name' => 'root.txt', - 'permissions' => 31, - 'mimetype' => 'application/pdf', - 'size' => 1234, - 'type' => 'file', - 'etag' => 'MyEtag', - 'path' => '/', - 'tags' => [ - [ - 'MyTagName' - ] - ], - ], - [ - 'id' => null, - 'parentId' => null, - 'mtime' => 999000, - 'name' => 'root.txt', - 'permissions' => 31, - 'mimetype' => 'application/binary', - 'size' => 9876, - 'type' => 'file', - 'etag' => 'SubEtag', - 'path' => '/', - 'tags' => [ - [ - 'MyTagName' - ] - ], - ] - ], - ]); - $this->assertEquals($expected, $this->apiController->getFilesByTag([$tagName])); - } - public function testUpdateFileTagsEmpty() { $expected = new DataResponse([]); $this->assertEquals($expected, $this->apiController->updateFileTags('/path.txt')); |