summaryrefslogtreecommitdiffstats
path: root/apps/files/tests/Controller/ApiControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/tests/Controller/ApiControllerTest.php')
-rw-r--r--apps/files/tests/Controller/ApiControllerTest.php176
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'));