summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-08-11 16:31:54 +0200
committerJoas Schilling <nickvergessen@owncloud.com>2015-08-26 11:54:24 +0200
commit16e5c15c283c40fd9c7a3f009f054b825bcadbb7 (patch)
tree6e2fdcdda72db2bba62a79e423d849db41ae0808 /apps
parentad450d4f0ed4ebbb5e9e6256750061b0adb950e1 (diff)
downloadnextcloud-server-16e5c15c283c40fd9c7a3f009f054b825bcadbb7.tar.gz
nextcloud-server-16e5c15c283c40fd9c7a3f009f054b825bcadbb7.zip
Add tests for "getRemote()"
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/tests/api/sharees.php85
1 files changed, 84 insertions, 1 deletions
diff --git a/apps/files_sharing/tests/api/sharees.php b/apps/files_sharing/tests/api/sharees.php
index 25074e4e8c4..04b8ef50253 100644
--- a/apps/files_sharing/tests/api/sharees.php
+++ b/apps/files_sharing/tests/api/sharees.php
@@ -34,6 +34,9 @@ class ShareesTest extends TestCase {
/** @var \OCP\IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
protected $groupManager;
+ /** @var \OCP\Contacts\IManager|\PHPUnit_Framework_MockObject_MockObject */
+ protected $contactsManager;
+
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */
protected $session;
@@ -48,6 +51,10 @@ class ShareesTest extends TestCase {
->disableOriginalConstructor()
->getMock();
+ $this->contactsManager = $this->getMockBuilder('OCP\Contacts\IManager')
+ ->disableOriginalConstructor()
+ ->getMock();
+
$this->session = $this->getMockBuilder('OCP\IUserSession')
->disableOriginalConstructor()
->getMock();
@@ -55,7 +62,7 @@ class ShareesTest extends TestCase {
$this->sharees = new Sharees(
$this->groupManager,
$this->userManager,
- $this->getMockBuilder('OCP\Contacts\IManager')->disableOriginalConstructor()->getMock(),
+ $this->contactsManager,
$this->getMockBuilder('OCP\IAppConfig')->disableOriginalConstructor()->getMock(),
$this->session,
$this->getMockBuilder('OCP\IURLGenerator')->disableOriginalConstructor()->getMock()
@@ -261,6 +268,82 @@ class ShareesTest extends TestCase {
$this->assertEquals($expected, $users);
}
+ public function dataGetRemote() {
+ return [
+ ['test', [], []],
+ [
+ 'test@remote',
+ [],
+ [
+ ['label' => 'test@remote', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
+ ],
+ ],
+ [
+ 'test',
+ [
+ [
+ 'FN' => 'User3 @ Localhost',
+ ],
+ [
+ 'FN' => 'User2 @ Localhost',
+ 'CLOUD' => [
+ ],
+ ],
+ [
+ 'FN' => 'User @ Localhost',
+ 'CLOUD' => [
+ 'username@localhost',
+ ],
+ ],
+ ],
+ [
+ ['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost']],
+ ],
+ ],
+ [
+ 'test@remote',
+ [
+ [
+ 'FN' => 'User3 @ Localhost',
+ ],
+ [
+ 'FN' => 'User2 @ Localhost',
+ 'CLOUD' => [
+ ],
+ ],
+ [
+ 'FN' => 'User @ Localhost',
+ 'CLOUD' => [
+ 'username@localhost',
+ ],
+ ],
+ ],
+ [
+ ['label' => 'test@remote', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']],
+ ['label' => 'User @ Localhost (username@localhost)', 'value' => ['shareType' => \OCP\Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost']],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGetRemote
+ *
+ * @param string $searchTerm
+ * @param array $contacts
+ * @param array $expected
+ */
+ public function testGetRemote($searchTerm, $contacts, $expected) {
+ $this->contactsManager->expects($this->any())
+ ->method('search')
+ ->with($searchTerm, ['CLOUD', 'FN'])
+ ->willReturn($contacts);
+
+ $users = $this->invokePrivate($this->sharees, 'getRemote', [$searchTerm]);
+
+ $this->assertEquals($expected, $users);
+ }
+
// public function testArguments() {
//
// }