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


PHP IUserManager::expects方法代码示例

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


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

示例1: testGetAvatarValidUser

 public function testGetAvatarValidUser()
 {
     $this->userManager->expects($this->once())->method('get')->with('validUser')->willReturn(true);
     $folder = $this->getMock('\\OCP\\Files\\Folder');
     $this->rootFolder->expects($this->once())->method('getUserFolder')->with('validUser')->willReturn($folder);
     $folder->expects($this->once())->method('getParent')->will($this->returnSelf());
     $this->avatarManager->getAvatar('validUser');
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:8,代码来源:avatarmanagertest.php

示例2: testImpersonate

 /**
  * @dataProvider usersProvider
  * @param $query
  * @param $uid
  */
 public function testImpersonate($query, $uid)
 {
     $user = $this->getMock('\\OCP\\IUser');
     $user->expects($this->once())->method('getUID')->will($this->returnValue($uid));
     $this->userManager->expects($this->once())->method('search')->with($query, 1, 0)->will($this->returnValue([$user]));
     $this->userSession->expects($this->once())->method('setUser')->with($user);
     $this->assertEquals(new JSONResponse(), $this->controller->impersonate($query));
 }
开发者ID:AARNet,项目名称:impersonate,代码行数:13,代码来源:settingscontrollertest.php

示例3: testRunWithUsersAndOffsetAtEndOfUserList

 public function testRunWithUsersAndOffsetAtEndOfUserList()
 {
     $this->config->expects($this->at(0))->method('getAppValue')->with('files', 'cronjob_scan_files', 0)->will($this->returnValue(50));
     $this->userManager->expects($this->at(0))->method('search')->with('', 500, 50)->will($this->returnValue([]));
     $this->userManager->expects($this->at(1))->method('search')->with('', 500)->will($this->returnValue([]));
     $this->config->expects($this->at(1))->method('setAppValue')->with('files', 'cronjob_scan_files', 500);
     $this->scanFiles->expects($this->never())->method('runScanner');
     $this->invokePrivate($this->scanFiles, 'run', [[]]);
 }
开发者ID:gmurayama,项目名称:core,代码行数:9,代码来源:ScanFilesTest.php

示例4: testStartMigrationSuccessful

 public function testStartMigrationSuccessful()
 {
     $migration = $this->getMockBuilder('\\OCA\\Encryption\\Migration')->disableOriginalConstructor()->getMock();
     $this->encryptionController->expects($this->once())->method('getMigration')->with($this->config, $this->view, $this->connection, $this->logger)->will($this->returnValue($migration));
     $migration->expects($this->once())->method('reorganizeSystemFolderStructure');
     $migration->expects($this->once())->method('updateDB');
     $backend = $this->getMockBuilder('\\OCP\\UserInterface')->getMock();
     $this->userManager->expects($this->once())->method('getBackends')->will($this->returnValue([$backend]));
     $backend->expects($this->once())->method('getUsers')->will($this->returnValue(['User 1', 'User 2']));
     $migration->expects($this->exactly(2))->method('reorganizeFolderStructureForUser')->withConsecutive(['User 1'], ['User 2']);
     $migration->expects($this->once())->method('finalCleanUp');
     $expected = ['data' => ['message' => 'Migration Completed'], 'status' => 'success'];
     $this->assertSame($expected, $this->encryptionController->startMigration());
 }
开发者ID:evanjt,项目名称:core,代码行数:14,代码来源:EncryptionControllerTest.php

示例5: testGetUsers

 /**
  * @dataProvider dataGetUsers
  *
  * @param string $searchTerm
  * @param bool $shareWithGroupOnly
  * @param bool $shareeEnumeration
  * @param array $groupResponse
  * @param array $userResponse
  * @param array $exactExpected
  * @param array $expected
  * @param bool $reachedEnd
  * @param mixed $singleUser
  */
 public function testGetUsers($searchTerm, $shareWithGroupOnly, $shareeEnumeration, $groupResponse, $userResponse, $exactExpected, $expected, $reachedEnd, $singleUser)
 {
     $this->invokePrivate($this->sharees, 'limit', [2]);
     $this->invokePrivate($this->sharees, 'offset', [0]);
     $this->invokePrivate($this->sharees, 'shareWithGroupOnly', [$shareWithGroupOnly]);
     $this->invokePrivate($this->sharees, 'shareeEnumeration', [$shareeEnumeration]);
     $user = $this->getUserMock('admin', 'Administrator');
     $this->session->expects($this->any())->method('getUser')->willReturn($user);
     if (!$shareWithGroupOnly) {
         $this->userManager->expects($this->once())->method('searchDisplayName')->with($searchTerm, $this->invokePrivate($this->sharees, 'limit'), $this->invokePrivate($this->sharees, 'offset'))->willReturn($userResponse);
     } else {
         if ($singleUser !== false) {
             $this->groupManager->expects($this->exactly(2))->method('getUserGroupIds')->withConsecutive($user, $singleUser)->willReturn($groupResponse);
         } else {
             $this->groupManager->expects($this->once())->method('getUserGroupIds')->with($user)->willReturn($groupResponse);
         }
         $this->groupManager->expects($this->exactly(sizeof($groupResponse)))->method('displayNamesInGroup')->with($this->anything(), $searchTerm, $this->invokePrivate($this->sharees, 'limit'), $this->invokePrivate($this->sharees, 'offset'))->willReturnMap($userResponse);
     }
     if ($singleUser !== false) {
         $this->userManager->expects($this->once())->method('get')->with($searchTerm)->willReturn($singleUser);
     }
     $this->invokePrivate($this->sharees, 'getUsers', [$searchTerm]);
     $result = $this->invokePrivate($this->sharees, 'result');
     $this->assertEquals($exactExpected, $result['exact']['users']);
     $this->assertEquals($expected, $result['users']);
     $this->assertCount((int) $reachedEnd, $this->invokePrivate($this->sharees, 'reachedEndFor'));
 }
开发者ID:lchen01,项目名称:STEdwards,代码行数:40,代码来源:shareestest.php

示例6: testCreatePublicity

 public function testCreatePublicity()
 {
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('setApp')->with('announcementcenter')->willReturnSelf();
     $event->expects($this->once())->method('setType')->with('announcementcenter')->willReturnSelf();
     $event->expects($this->once())->method('setAuthor')->with('author')->willReturnSelf();
     $event->expects($this->once())->method('setTimestamp')->with(1337)->willReturnSelf();
     $event->expects($this->once())->method('setSubject')->with('announcementsubject#10', ['author'])->willReturnSelf();
     $event->expects($this->once())->method('setMessage')->with('announcementmessage#10', ['author'])->willReturnSelf();
     $event->expects($this->once())->method('setObject')->with('announcement', 10)->willReturnSelf();
     $event->expects($this->exactly(5))->method('setAffectedUser')->willReturnSelf();
     $notification = $this->getMockBuilder('OC\\Notification\\INotification')->disableOriginalConstructor()->getMock();
     $notification->expects($this->once())->method('setApp')->with('announcementcenter')->willReturnSelf();
     $dateTime = new \DateTime();
     $dateTime->setTimestamp(1337);
     $notification->expects($this->once())->method('setDateTime')->with($dateTime)->willReturnSelf();
     $notification->expects($this->once())->method('setSubject')->with('announced', ['author'])->willReturnSelf();
     $notification->expects($this->once())->method('setObject')->with('announcement', 10)->willReturnSelf();
     $notification->expects($this->once())->method('setLink')->willReturnSelf();
     $notification->expects($this->exactly(4))->method('setUser')->willReturnSelf();
     $controller = $this->getController();
     $this->activityManager->expects($this->once())->method('generateEvent')->willReturn($event);
     $this->notificationManager->expects($this->once())->method('createNotification')->willReturn($notification);
     $this->userManager->expects($this->once())->method('search')->with('')->willReturn([$this->getUserMock('author', 'User One'), $this->getUserMock('u2', 'User Two'), $this->getUserMock('u3', 'User Three'), $this->getUserMock('u4', 'User Four'), $this->getUserMock('u5', 'User Five')]);
     $this->activityManager->expects($this->exactly(5))->method('publish');
     $this->notificationManager->expects($this->exactly(4))->method('notify');
     $this->invokePrivate($controller, 'createPublicity', [10, 'author', 1337]);
 }
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:28,代码来源:PageControllerTest.php

示例7: testGetGroupMembershipEmpty

	/**
	 * @expectedException \Sabre\DAV\Exception
	 * @expectedExceptionMessage Principal not found
	 */
	public function testGetGroupMembershipEmpty() {
		$this->userManager
			->expects($this->once())
			->method('get')
			->with('foo')
			->will($this->returnValue(null));

		$this->connector->getGroupMembership('principals/foo');
	}
开发者ID:ninjasilicon,项目名称:core,代码行数:13,代码来源:principal.php

示例8: testFormat

 /**
  * @dataProvider dataFormat
  *
  * @param string $parameter
  * @param null|\OCP\IUser $user
  * @param bool $avatarsEnabled
  * @param bool $allowHtml
  * @param bool $verbose
  * @param string $expected
  */
 public function testFormat($parameter, $user, $avatarsEnabled, $allowHtml, $verbose, $expected)
 {
     /** @var \OCP\Activity\IEvent|\PHPUnit_Framework_MockObject_MockObject $event */
     $event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
     $this->l->expects($this->never())->method('t');
     $this->userManager->expects($this->once())->method('get')->with($parameter)->willReturn($user);
     $this->config->expects($this->any())->method('getSystemValue')->with('enable_avatars', true)->willReturn($avatarsEnabled);
     $formatter = $this->getFormatter();
     $this->assertSame($expected, $formatter->format($event, $parameter, $allowHtml, $verbose));
 }
开发者ID:ynott,项目名称:activity,代码行数:20,代码来源:userformattertest.php

示例9: testGetUserSubAdminGroupsWithoutGroups

 public function testGetUserSubAdminGroupsWithoutGroups()
 {
     $targetUser = $this->getMock('\\OCP\\IUser');
     $this->userManager->expects($this->once())->method('get')->with('RequestedUser')->will($this->returnValue($targetUser));
     $subAdminManager = $this->getMockBuilder('\\OC\\Subadmin')->disableOriginalConstructor()->getMock();
     $subAdminManager->expects($this->once())->method('getSubAdminsGroups')->with($targetUser)->will($this->returnValue([]));
     $this->groupManager->expects($this->once())->method('getSubAdmin')->will($this->returnValue($subAdminManager));
     $expected = new \OC_OCS_Result(null, 102, 'Unknown error occurred');
     $this->assertEquals($expected, $this->api->getUserSubAdminGroups(['userid' => 'RequestedUser']));
 }
开发者ID:rajeshpillai,项目名称:core,代码行数:10,代码来源:userstest.php

示例10: testShowLoginFormForUserNamedNull

 public function testShowLoginFormForUserNamedNull()
 {
     $this->userSession->expects($this->once())->method('isLoggedIn')->willReturn(false);
     $this->config->expects($this->once())->method('getSystemValue')->with('lost_password_link')->willReturn(false);
     $user = $this->getMock('\\OCP\\IUser');
     $user->expects($this->once())->method('canChangePassword')->willReturn(false);
     $this->userManager->expects($this->once())->method('get')->with('0')->willReturn($user);
     $expectedResponse = new TemplateResponse('core', 'login', ['messages' => [], 'loginName' => '0', 'user_autofocus' => false, 'canResetPassword' => false, 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0], 'guest');
     $this->assertEquals($expectedResponse, $this->loginController->showLoginForm('0', '', ''));
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:10,代码来源:LoginControllerTest.php

示例11: testRun

 public function testRun()
 {
     $cat1 = $this->addTagCategory('TestRepairCleanTags', 'files');
     // Retained
     $cat2 = $this->addTagCategory('TestRepairCleanTags2', 'files');
     // Deleted: Category will be empty
     $this->addTagCategory('TestRepairCleanTags3', 'files');
     // Deleted: Category is empty
     $cat3 = $this->addTagCategory('TestRepairCleanTags', 'contacts');
     // Retained
     $this->addTagEntry($this->getFileID(), $cat2, 'files');
     // Retained
     $this->addTagEntry($this->getFileID() + 1, $cat1, 'files');
     // Deleted: File is NULL
     $this->addTagEntry(9999999, $cat3, 'contacts');
     // Retained
     $this->addTagEntry($this->getFileID(), $cat3 + 1, 'files');
     // Deleted: Category is NULL
     $this->assertEntryCount('vcategory_to_object', 4, 'Assert tag entries count before repair step');
     $this->assertEntryCount('vcategory', 4, 'Assert tag categories count before repair step');
     self::invokePrivate($this->repair, 'deleteOrphanFileEntries', [$this->outputMock]);
     $this->assertEntryCount('vcategory_to_object', 3, 'Assert tag entries count after cleaning file entries');
     $this->assertEntryCount('vcategory', 4, 'Assert tag categories count after cleaning file entries');
     self::invokePrivate($this->repair, 'deleteOrphanTagEntries', [$this->outputMock]);
     $this->assertEntryCount('vcategory_to_object', 2, 'Assert tag entries count after cleaning tag entries');
     $this->assertEntryCount('vcategory', 4, 'Assert tag categories count after cleaning tag entries');
     self::invokePrivate($this->repair, 'deleteOrphanCategoryEntries', [$this->outputMock]);
     $this->assertEntryCount('vcategory_to_object', 2, 'Assert tag entries count after cleaning category entries');
     $this->assertEntryCount('vcategory', 2, 'Assert tag categories count after cleaning category entries');
     $this->addTagCategory('TestRepairCleanTags', 'contacts', 'userExists');
     // Retained
     $this->assertEntryCount('vcategory', 3, 'Assert tag categories count before cleaning categories by users');
     $this->userManager->expects($this->exactly(2))->method('userExists')->willReturnMap([['userExists', true], ['TestRepairCleanTags', false]]);
     self::invokePrivate($this->repair, 'deleteOrphanTags', [$this->outputMock]);
     $this->assertEntryCount('vcategory', 1, 'Assert tag categories count after cleaning categories by users');
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:36,代码来源:CleanTagsTest.php

示例12: testUpdatePrivateKeyPassword

 /**
  * test updatePrivateKeyPassword() with the correct old and new password
  */
 public function testUpdatePrivateKeyPassword()
 {
     $oldPassword = 'old';
     $newPassword = 'new';
     $this->ocSessionMock->expects($this->once())->method('get')->with('loginname')->willReturn('testUser');
     $this->userManagerMock->expects($this->at(0))->method('checkPassword')->with('testUserUid', 'new')->willReturn(false);
     $this->userManagerMock->expects($this->at(1))->method('checkPassword')->with('testUser', 'new')->willReturn(true);
     $this->cryptMock->expects($this->once())->method('decryptPrivateKey')->willReturn('decryptedKey');
     $this->cryptMock->expects($this->once())->method('encryptPrivateKey')->willReturn('encryptedKey');
     $this->cryptMock->expects($this->once())->method('generateHeader')->willReturn('header.');
     // methods which must be called after successful changing the key password
     $this->keyManagerMock->expects($this->once())->method('setPrivateKey')->with($this->equalTo('testUserUid'), $this->equalTo('header.encryptedKey'));
     $this->sessionMock->expects($this->once())->method('setPrivateKey')->with($this->equalTo('decryptedKey'));
     $this->sessionMock->expects($this->once())->method('setStatus')->with($this->equalTo(Session::INIT_SUCCESSFUL));
     $result = $this->controller->updatePrivateKeyPassword($oldPassword, $newPassword);
     $data = $result->getData();
     $this->assertSame(Http::STATUS_OK, $result->getStatus());
     $this->assertSame('Private key password successfully updated.', $data['message']);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:22,代码来源:SettingsControllerTest.php

示例13: testSendEmailToUser

 public function testSendEmailToUser()
 {
     $maxTime = 200;
     $user = 'user2';
     $userDisplayName = 'user two';
     $email = $user . '@localhost';
     $this->mailer->expects($this->once())->method('send')->with($this->message);
     $this->message->expects($this->once())->method('setTo')->with([$email => $userDisplayName]);
     $this->message->expects($this->once())->method('setSubject');
     $this->message->expects($this->once())->method('setPlainBody');
     $this->message->expects($this->once())->method('setFrom');
     $userObject = $this->getMock('OCP\\IUser');
     $userObject->expects($this->any())->method('getDisplayName')->willReturn($userDisplayName);
     $this->userManager->expects($this->any())->method('get')->willReturnMap([[$user, $userObject], [$user . $user, null]]);
     $users = $this->mailQueueHandler->getAffectedUsers(1, $maxTime);
     $this->assertEquals([$user], $users);
     $this->mailQueueHandler->sendEmailToUser($user, $email, 'en', 'UTC', $maxTime);
     // Invalid user, no object no email
     $this->mailQueueHandler->sendEmailToUser($user . $user, $email, 'en', 'UTC', $maxTime);
 }
开发者ID:arietimmerman,项目名称:activity,代码行数:20,代码来源:mailqueuehandlertest.php

示例14: testUpdateShareUser

 public function testUpdateShareUser()
 {
     $this->userManager->expects($this->any())->method('userExists')->willReturn(true);
     $manager = $this->createManagerMock()->setMethods(['canShare', 'getShareById', 'generalCreateChecks', 'userCreateChecks', 'pathCreateChecks'])->getMock();
     $originalShare = $this->manager->newShare();
     $originalShare->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith('origUser')->setPermissions(1);
     $node = $this->getMock('\\OCP\\Files\\File');
     $node->method('getId')->willReturn(100);
     $node->method('getPath')->willReturn('/newUser/files/myPath');
     $manager->expects($this->once())->method('canShare')->willReturn(true);
     $manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
     $share = $this->manager->newShare();
     $share->setProviderId('foo')->setId('42')->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith('origUser')->setShareOwner('newUser')->setSharedBy('sharer')->setPermissions(31)->setNode($node);
     $this->defaultProvider->expects($this->once())->method('update')->with($share)->willReturn($share);
     $hookListner = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
     \OCP\Util::connectHook('OCP\\Share', 'post_set_expiration_date', $hookListner, 'post');
     $hookListner->expects($this->never())->method('post');
     $this->rootFolder->method('getUserFolder')->with('newUser')->will($this->returnSelf());
     $this->rootFolder->method('getRelativePath')->with('/newUser/files/myPath')->willReturn('/myPath');
     $hookListner2 = $this->getMockBuilder('Dummy')->setMethods(['post'])->getMock();
     \OCP\Util::connectHook('OCP\\Share', 'post_update_permissions', $hookListner2, 'post');
     $hookListner2->expects($this->once())->method('post')->with(['itemType' => 'file', 'itemSource' => 100, 'shareType' => \OCP\Share::SHARE_TYPE_USER, 'shareWith' => 'origUser', 'uidOwner' => 'sharer', 'permissions' => 31, 'path' => '/myPath']);
     $manager->updateShare($share);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:24,代码来源:ManagerTest.php


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