diff options
Diffstat (limited to 'apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php')
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index c570cb16980..c68e2304743 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -133,7 +133,7 @@ class ShareesAPIControllerTest extends TestCase { * @param string $gid * @return \OCP\IGroup|\PHPUnit_Framework_MockObject_MockObject */ - protected function getGroupMock($gid) { + protected function getGroupMock($gid, $displayName = null) { $group = $this->getMockBuilder('OCP\IGroup') ->disableOriginalConstructor() ->getMock(); @@ -142,6 +142,15 @@ class ShareesAPIControllerTest extends TestCase { ->method('getGID') ->willReturn($gid); + if (is_null($displayName)) { + // note: this is how the Group class behaves + $displayName = $gid; + } + + $group->expects($this->any()) + ->method('getDisplayName') + ->willReturn($displayName); + return $group; } @@ -467,6 +476,7 @@ class ShareesAPIControllerTest extends TestCase { return [ ['test', false, true, [], [], [], [], true, false], ['test', false, false, [], [], [], [], true, false], + // group without display name [ 'test', false, true, [$this->getGroupMock('test1')], @@ -476,6 +486,36 @@ class ShareesAPIControllerTest extends TestCase { true, false, ], + // group with display name, search by id + [ + 'test', false, true, + [$this->getGroupMock('test1', 'Test One')], + [], + [], + [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + true, + false, + ], + // group with display name, search by display name + [ + 'one', false, true, + [$this->getGroupMock('test1', 'Test One')], + [], + [], + [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + true, + false, + ], + // group with display name, search by display name, exact expected + [ + 'Test One', false, true, + [$this->getGroupMock('test1', 'Test One')], + [], + [['label' => 'Test One', 'value' => ['shareType' => Share::SHARE_TYPE_GROUP, 'shareWith' => 'test1']]], + [], + true, + false, + ], [ 'test', false, false, [$this->getGroupMock('test1')], |