当前位置: 首页>>代码示例>>PHP>>正文


PHP IGroupManager::expects方法代码示例

本文整理汇总了PHP中OCP\IGroupManager::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP IGroupManager::expects方法的具体用法?PHP IGroupManager::expects怎么用?PHP IGroupManager::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\IGroupManager的用法示例。


在下文中一共展示了IGroupManager::expects方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetShareByIdGroupShare

 public function testGetShareByIdGroupShare()
 {
     $qb = $this->dbConn->getQueryBuilder();
     $qb->insert('share')->values(['share_type' => $qb->expr()->literal(\OCP\Share::SHARE_TYPE_GROUP), 'share_with' => $qb->expr()->literal('sharedWith'), 'uid_owner' => $qb->expr()->literal('sharedBy'), 'item_type' => $qb->expr()->literal('file'), 'file_source' => $qb->expr()->literal(42), 'file_target' => $qb->expr()->literal('myTarget'), 'permissions' => $qb->expr()->literal(13)]);
     $this->assertEquals(1, $qb->execute());
     // Get the id
     $qb = $this->dbConn->getQueryBuilder();
     $cursor = $qb->select('id')->from('share')->setMaxResults(1)->orderBy('id', 'DESC')->execute();
     $id = $cursor->fetch();
     $id = $id['id'];
     $cursor->closeCursor();
     $storage = $this->getMock('OC\\Files\\Storage\\Storage');
     $storage->expects($this->once())->method('getOwner')->willReturn('shareOwner');
     $path = $this->getMock('OCP\\Files\\Folder');
     $path->expects($this->once())->method('getStorage')->wilLReturn($storage);
     $this->userFolder->expects($this->once())->method('getById')->with(42)->willReturn([$path]);
     $sharedWith = $this->getMock('OCP\\IGroup');
     $sharedBy = $this->getMock('OCP\\IUser');
     $shareOwner = $this->getMock('OCP\\IUser');
     $this->userManager->method('get')->will($this->returnValueMap([['sharedBy', $sharedBy], ['shareOwner', $shareOwner]]));
     $this->groupManager->expects($this->once())->method('get')->with('sharedWith')->willReturn($sharedWith);
     $share = $this->provider->getShareById($id);
     $this->assertEquals($id, $share->getId());
     $this->assertEquals(\OCP\Share::SHARE_TYPE_GROUP, $share->getShareType());
     $this->assertEquals($sharedWith, $share->getSharedWith());
     $this->assertEquals($sharedBy, $share->getSharedBy());
     $this->assertEquals($shareOwner, $share->getShareOwner());
     $this->assertEquals($path, $share->getPath());
     $this->assertEquals(13, $share->getPermissions());
     $this->assertEquals(null, $share->getToken());
     $this->assertEquals(null, $share->getExpirationDate());
     $this->assertEquals('myTarget', $share->getTarget());
 }
开发者ID:hassanhawilo,项目名称:core,代码行数:33,代码来源:defaultshareprovidertest.php

示例2: testIndex

 /**
  * @dataProvider dataIndex
  * @param bool $isAdmin
  */
 public function testIndex($isAdmin)
 {
     $this->groupManager->expects($this->once())->method('isAdmin')->with('author')->willReturn($isAdmin);
     $controller = $this->getController();
     $response = $controller->index();
     $this->assertInstanceOf('OCP\\AppFramework\\Http\\TemplateResponse', $response);
     $this->assertSame(['is_admin' => $isAdmin], $response->getParams());
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:12,代码来源:PageControllerTest.php

示例3: testAddGroupWithSpecialChar

 public function testAddGroupWithSpecialChar()
 {
     $this->request->method('getParam')->with('groupid')->willReturn('Iñtërnâtiônàlizætiøn');
     $this->groupManager->method('groupExists')->with('Iñtërnâtiônàlizætiøn')->willReturn(false);
     $this->groupManager->expects($this->once())->method('createGroup')->with('Iñtërnâtiônàlizætiøn');
     $result = $this->api->addGroup([]);
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertTrue($result->succeeded());
 }
开发者ID:kenwi,项目名称:core,代码行数:9,代码来源:groupstest.php

示例4: testGetAppsForUser

 public function testGetAppsForUser()
 {
     $user = new User('user1', null);
     $this->groupManager->expects($this->any())->method('getUserGroupIds')->with($user)->will($this->returnValue(array('foo', 'bar')));
     $this->appConfig->setValue('test1', 'enabled', 'yes');
     $this->appConfig->setValue('test2', 'enabled', 'no');
     $this->appConfig->setValue('test3', 'enabled', '["foo"]');
     $this->appConfig->setValue('test4', 'enabled', '["asd"]');
     $this->assertEquals(['dav', 'federatedfilesharing', 'files', 'test1', 'test3'], $this->manager->getEnabledAppsForUser($user));
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:10,代码来源:manager.php

示例5: testAssignabilityCheck

 /**
  * @dataProvider assignabilityCheckProvider
  */
 public function testAssignabilityCheck($userVisible, $userAssignable, $isAdmin, $expectedResult, $userGroupIds = [], $tagGroupIds = [])
 {
     $user = $this->getMockBuilder('\\OCP\\IUser')->getMock();
     $user->expects($this->any())->method('getUID')->will($this->returnValue('test'));
     $tag1 = $this->tagManager->createTag('one', $userVisible, $userAssignable);
     $this->tagManager->setTagGroups($tag1, $tagGroupIds);
     $this->groupManager->expects($this->any())->method('isAdmin')->with('test')->will($this->returnValue($isAdmin));
     $this->groupManager->expects($this->any())->method('getUserGroupIds')->with($user)->will($this->returnValue($userGroupIds));
     $this->assertEquals($expectedResult, $this->tagManager->canUserAssignTag($tag1, $user));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:13,代码来源:SystemTagManagerTest.php

示例6: testRun

 public function testRun()
 {
     $repair = new OldGroupMembershipShares($this->connection, $this->groupManager);
     $this->groupManager->expects($this->exactly(2))->method('isInGroup')->willReturnMap([['member', 'group', true], ['not-a-member', 'group', false]]);
     $parent = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group', null);
     $group2 = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group2', $parent);
     $user1 = $this->createShare(Constants::SHARE_TYPE_USER, 'user1', $parent);
     // \OC\Share\Constant::$shareTypeGroupUserUnique === 2
     $member = $this->createShare(2, 'member', $parent);
     $notAMember = $this->createShare(2, 'not-a-member', $parent);
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertSame([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member], ['id' => $notAMember]], $rows);
     $result->closeCursor();
     $repair->run();
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertSame([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member]], $rows);
     $result->closeCursor();
 }
开发者ID:rajeshpillai,项目名称:core,代码行数:22,代码来源:oldgroupmembershipsharestest.php

示例7: testProcessFilterRulesVisibleTagAsUser

 public function testProcessFilterRulesVisibleTagAsUser()
 {
     $this->groupManager->expects($this->any())->method('isAdmin')->will($this->returnValue(false));
     $tag1 = $this->getMock('\\OCP\\SystemTag\\ISystemTag');
     $tag1->expects($this->any())->method('getId')->will($this->returnValue('123'));
     $tag1->expects($this->any())->method('isUserVisible')->will($this->returnValue(true));
     $tag2 = $this->getMock('\\OCP\\SystemTag\\ISystemTag');
     $tag2->expects($this->any())->method('getId')->will($this->returnValue('123'));
     $tag2->expects($this->any())->method('isUserVisible')->will($this->returnValue(true));
     $this->tagManager->expects($this->once())->method('getTagsByIds')->with(['123', '456'])->will($this->returnValue([$tag1, $tag2]));
     $this->tagMapper->expects($this->at(0))->method('getObjectIdsForTags')->with('123')->will($this->returnValue(['111', '222']));
     $this->tagMapper->expects($this->at(1))->method('getObjectIdsForTags')->with('456')->will($this->returnValue(['222', '333']));
     $rules = [['name' => '{http://owncloud.org/ns}systemtag', 'value' => '123'], ['name' => '{http://owncloud.org/ns}systemtag', 'value' => '456']];
     $this->assertEquals(['222'], array_values($this->invokePrivate($this->plugin, 'processFilterRules', [$rules])));
 }
开发者ID:gvde,项目名称:core,代码行数:15,代码来源:filesreportplugin.php

示例8: testRun

 public function testRun()
 {
     $repair = new OldGroupMembershipShares($this->connection, $this->groupManager);
     $this->groupManager->expects($this->exactly(2))->method('isInGroup')->willReturnMap([['member', 'group', true], ['not-a-member', 'group', false]]);
     $parent = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group', null);
     $group2 = $this->createShare(Constants::SHARE_TYPE_GROUP, 'group2', $parent);
     $user1 = $this->createShare(Constants::SHARE_TYPE_USER, 'user1', $parent);
     // \OC\Share\Constant::$shareTypeGroupUserUnique === 2
     $member = $this->createShare(2, 'member', $parent);
     $notAMember = $this->createShare(2, 'not-a-member', $parent);
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member], ['id' => $notAMember]], $rows);
     $result->closeCursor();
     /** @var IOutput | \PHPUnit_Framework_MockObject_MockObject $outputMock */
     $outputMock = $this->getMockBuilder('\\OCP\\Migration\\IOutput')->disableOriginalConstructor()->getMock();
     $repair->run($outputMock);
     $query = $this->connection->getQueryBuilder();
     $result = $query->select('id')->from('share')->orderBy('id', 'ASC')->execute();
     $rows = $result->fetchAll();
     $this->assertEquals([['id' => $parent], ['id' => $group2], ['id' => $user1], ['id' => $member]], $rows);
     $result->closeCursor();
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:24,代码来源:OldGroupMembershipSharesTest.php

示例9: testCreateTagConflict

 /**
  * @dataProvider nodeClassProvider
  * @expectedException \Sabre\DAV\Exception\Conflict
  */
 public function testCreateTagConflict($nodeClass)
 {
     $this->user->expects($this->once())->method('getUID')->willReturn('admin');
     $this->groupManager->expects($this->once())->method('isAdmin')->with('admin')->willReturn(true);
     $requestData = json_encode(['name' => 'Test', 'userVisible' => true, 'userAssignable' => false]);
     $node = $this->getMockBuilder($nodeClass)->disableOriginalConstructor()->getMock();
     $this->tagManager->expects($this->once())->method('createTag')->with('Test', true, false)->will($this->throwException(new TagAlreadyExistsException('Tag already exists')));
     $this->tree->expects($this->any())->method('getNodeForPath')->with('/systemtags')->will($this->returnValue($node));
     $request = $this->getMockBuilder('Sabre\\HTTP\\RequestInterface')->disableOriginalConstructor()->getMock();
     $response = $this->getMockBuilder('Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $request->expects($this->once())->method('getPath')->will($this->returnValue('/systemtags'));
     $request->expects($this->once())->method('getBodyAsString')->will($this->returnValue($requestData));
     $request->expects($this->once())->method('getHeader')->with('Content-Type')->will($this->returnValue('application/json'));
     $this->plugin->httpPost($request, $response);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:19,代码来源:SystemTagPluginTest.php

示例10: testShareFileOrFolderWithGroup

 /**
  * @dataProvider dataShareFileOrFolderWithGroup
  * @param array $usersInGroup
  * @param array $settingUsers
  * @param array $settingsReturn
  * @param array $addNotifications
  */
 public function testShareFileOrFolderWithGroup($usersInGroup, $settingUsers, $settingsReturn, $addNotifications)
 {
     $filesHooks = $this->getFilesHooks(['shareNotificationForSharer', 'addNotificationsForUser', 'fixPathsForShareExceptions', 'shareNotificationForOriginalOwners']);
     $group = $this->getMockBuilder('OCP\\IGroup')->disableOriginalConstructor()->getMock();
     $group->expects($this->once())->method('searchUsers')->with('')->willReturn($usersInGroup);
     $this->groupManager->expects($this->once())->method('get')->with('group1')->willReturn($group);
     $this->settings->expects(empty($settingUsers) ? $this->never() : $this->exactly(2))->method('filterUsersBySetting')->willReturnMap($settingsReturn);
     $filesHooks->expects($this->once())->method('shareNotificationForSharer')->with('shared_group_self', 'group1', 42, 'file');
     $filesHooks->expects(empty($settingUsers) ? $this->never() : $this->once())->method('fixPathsForShareExceptions')->with($this->anything(), 1337)->willReturnArgument(0);
     $filesHooks->expects($this->once())->method('shareNotificationForOriginalOwners')->with('user', 'reshared_group_by', 'group1', 42, 'file')->willReturnArgument(0);
     $i = 3;
     foreach ($addNotifications as $user => $arguments) {
         $filesHooks->expects($this->at($i))->method('addNotificationsForUser')->with($user, $arguments['subject'], $arguments['subject_params'], 42, $arguments['path'], true, $arguments['stream'], $arguments['email'], Files_Sharing::TYPE_SHARED);
         $i++;
     }
     $this->invokePrivate($filesHooks, 'shareFileOrFolderWithGroup', ['group1', 42, 'file', '/file', 1337]);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:24,代码来源:fileshookstest.php

示例11: testGetUsersToNotify

 /**
  * @dataProvider dataGetUsersToNotify
  * @param string[] $groups
  * @param array $groupUsers
  * @param string[] $expected
  */
 public function testGetUsersToNotify($groups, array $groupUsers, array $expected)
 {
     $job = $this->getJob();
     $this->config->expects($this->once())->method('getAppValue')->with('updatenotification', 'notify_groups', '["admin"]')->willReturn(json_encode($groups));
     $groupMap = [];
     foreach ($groupUsers as $gid => $uids) {
         if ($uids === null) {
             $group = null;
         } else {
             $group = $this->getGroup($gid);
             $group->expects($this->any())->method('getUsers')->willReturn($this->getUsers($uids));
         }
         $groupMap[] = [$gid, $group];
     }
     $this->groupManager->expects($this->exactly(sizeof($groups)))->method('get')->willReturnMap($groupMap);
     $result = $this->invokePrivate($job, 'getUsersToNotify');
     $this->assertEquals($expected, $result);
     // Test caching
     $result = $this->invokePrivate($job, 'getUsersToNotify');
     $this->assertEquals($expected, $result);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:27,代码来源:BackgroundJobTest.php

示例12: testGetGroups

 /**
  * @dataProvider dataGetGroups
  *
  * @param string $searchTerm
  * @param bool $shareWithGroupOnly
  * @param array $groupResponse
  * @param array $userGroupsResponse
  * @param array $exactExpected
  * @param array $expected
  * @param bool $reachedEnd
  * @param mixed $singleGroup
  */
 public function testGetGroups($searchTerm, $shareWithGroupOnly, $groupResponse, $userGroupsResponse, $exactExpected, $expected, $reachedEnd, $singleGroup)
 {
     $this->invokePrivate($this->sharees, 'limit', [2]);
     $this->invokePrivate($this->sharees, 'offset', [0]);
     $this->invokePrivate($this->sharees, 'shareWithGroupOnly', [$shareWithGroupOnly]);
     $this->groupManager->expects($this->once())->method('search')->with($searchTerm, $this->invokePrivate($this->sharees, 'limit'), $this->invokePrivate($this->sharees, 'offset'))->willReturn($groupResponse);
     if ($singleGroup !== false) {
         $this->groupManager->expects($this->once())->method('get')->with($searchTerm)->willReturn($singleGroup);
     }
     if ($shareWithGroupOnly) {
         $user = $this->getUserMock('admin', 'Administrator');
         $this->session->expects($this->any())->method('getUser')->willReturn($user);
         $numGetUserGroupsCalls = empty($groupResponse) ? 0 : 1;
         $this->groupManager->expects($this->exactly($numGetUserGroupsCalls))->method('getUserGroups')->with($user)->willReturn($userGroupsResponse);
     }
     $this->invokePrivate($this->sharees, 'getGroups', [$searchTerm]);
     $result = $this->invokePrivate($this->sharees, 'result');
     $this->assertEquals($exactExpected, $result['exact']['groups']);
     $this->assertEquals($expected, $result['groups']);
     $this->assertCount((int) $reachedEnd, $this->invokePrivate($this->sharees, 'reachedEndFor'));
 }
开发者ID:ecompass,项目名称:core,代码行数:33,代码来源:shareestest.php


注:本文中的OCP\IGroupManager::expects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。