aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/tests
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-03-16 11:03:26 +0100
committerVincent Petry <pvince81@owncloud.com>2016-03-17 15:35:21 +0100
commit950530b162cb109d258ba23d041e8fd98c9a936e (patch)
tree5138f6b9484c337d28e07dd00146caf257e4f3b5 /apps/files/tests
parentf778e48ee5c9c80724d631190a1425eabc8d0df1 (diff)
downloadnextcloud-server-950530b162cb109d258ba23d041e8fd98c9a936e.tar.gz
nextcloud-server-950530b162cb109d258ba23d041e8fd98c9a936e.zip
Display share status info in favorite list
Returns the shareTypes share status info to the favorites file list.
Diffstat (limited to 'apps/files/tests')
-rw-r--r--apps/files/tests/controller/apicontrollertest.php56
1 files changed, 53 insertions, 3 deletions
diff --git a/apps/files/tests/controller/apicontrollertest.php b/apps/files/tests/controller/apicontrollertest.php
index 6fb8340ead8..a9b248a36fe 100644
--- a/apps/files/tests/controller/apicontrollertest.php
+++ b/apps/files/tests/controller/apicontrollertest.php
@@ -51,14 +51,27 @@ class ApiControllerTest extends TestCase {
private $preview;
/** @var ApiController */
private $apiController;
+ /** @var \OCP\Share\IManager */
+ private $shareManager;
public function setUp() {
$this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
+ $user = $this->getMock('\OCP\IUser');
+ $user->expects($this->any())
+ ->method('getUID')
+ ->will($this->returnValue('user1'));
+ $userSession = $this->getMock('\OCP\IUserSession');
+ $userSession->expects($this->any())
+ ->method('getUser')
+ ->will($this->returnValue($user));
$this->tagService = $this->getMockBuilder('\OCA\Files\Service\TagService')
->disableOriginalConstructor()
->getMock();
+ $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')
+ ->disableOriginalConstructor()
+ ->getMock();
$this->preview = $this->getMockBuilder('\OCP\IPreview')
->disableOriginalConstructor()
->getMock();
@@ -66,8 +79,10 @@ class ApiControllerTest extends TestCase {
$this->apiController = new ApiController(
$this->appName,
$this->request,
+ $userSession,
$this->tagService,
- $this->preview
+ $this->preview,
+ $this->shareManager
);
}
@@ -101,10 +116,32 @@ class ApiControllerTest extends TestCase {
->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([$fileInfo]));
+ ->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' => [
@@ -124,6 +161,7 @@ class ApiControllerTest extends TestCase {
'MyTagName'
]
],
+ 'shareTypes' => [\OCP\Share::SHARE_TYPE_USER, \OCP\Share::SHARE_TYPE_LINK]
],
],
]);
@@ -166,10 +204,22 @@ class ApiControllerTest extends TestCase {
->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([$fileInfo1, $fileInfo2]));
+ ->will($this->returnValue([$node1, $node2]));
$expected = new DataResponse([
'files' => [