當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ILogger::expects方法代碼示例

本文整理匯總了PHP中OCP\ILogger::expects方法的典型用法代碼示例。如果您正苦於以下問題:PHP ILogger::expects方法的具體用法?PHP ILogger::expects怎麽用?PHP ILogger::expects使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OCP\ILogger的用法示例。


在下文中一共展示了ILogger::expects方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAddUserAsSubAdminExistingGroups

 public function testAddUserAsSubAdminExistingGroups()
 {
     $_POST['userid'] = 'NewUser';
     $_POST['password'] = 'PasswordOfTheNewUser';
     $_POST['groups'] = ['ExistingGroup1', 'ExistingGroup2'];
     $this->userManager->expects($this->once())->method('userExists')->with('NewUser')->willReturn(false);
     $loggedInUser = $this->getMock('\\OCP\\IUser');
     $loggedInUser->expects($this->once())->method('getUID')->will($this->returnValue('subAdminUser'));
     $this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($loggedInUser));
     $this->groupManager->expects($this->once())->method('isAdmin')->with('subAdminUser')->willReturn(false);
     $this->groupManager->expects($this->exactly(2))->method('groupExists')->withConsecutive(['ExistingGroup1'], ['ExistingGroup2'])->willReturn(true);
     $user = $this->getMock('\\OCP\\IUser');
     $this->userManager->expects($this->once())->method('createUser')->with('NewUser', 'PasswordOfTheNewUser')->willReturn($user);
     $existingGroup1 = $this->getMock('\\OCP\\IGroup');
     $existingGroup2 = $this->getMock('\\OCP\\IGroup');
     $existingGroup1->expects($this->once())->method('addUser')->with($user);
     $existingGroup2->expects($this->once())->method('addUser')->with($user);
     $this->groupManager->expects($this->exactly(4))->method('get')->withConsecutive(['ExistingGroup1'], ['ExistingGroup2'], ['ExistingGroup1'], ['ExistingGroup2'])->will($this->returnValueMap([['ExistingGroup1', $existingGroup1], ['ExistingGroup2', $existingGroup2]]));
     $this->logger->expects($this->exactly(3))->method('info')->withConsecutive(['Successful addUser call with userid: NewUser', ['app' => 'ocs_api']], ['Added userid NewUser to group ExistingGroup1', ['app' => 'ocs_api']], ['Added userid NewUser to group ExistingGroup2', ['app' => 'ocs_api']]);
     $subAdminManager = $this->getMockBuilder('\\OC\\Subadmin')->disableOriginalConstructor()->getMock();
     $this->groupManager->expects($this->once())->method('getSubAdmin')->willReturn($subAdminManager);
     $subAdminManager->expects($this->once())->method('isSubAdmin')->with($loggedInUser)->willReturn(true);
     $subAdminManager->expects($this->exactly(2))->method('isSubAdminOfGroup')->withConsecutive([$loggedInUser, $existingGroup1], [$loggedInUser, $existingGroup2])->wilLReturn(true);
     $expected = new \OC_OCS_Result(null, 100);
     $this->assertEquals($expected, $this->api->addUser());
 }
開發者ID:DaubaKao,項目名稱:owncloud-core,代碼行數:26,代碼來源:userstest.php

示例2: testAddUserUnsuccessful

 public function testAddUserUnsuccessful()
 {
     $_POST['userid'] = 'NewUser';
     $_POST['password'] = 'PasswordOfTheNewUser';
     $this->userManager->expects($this->once())->method('userExists')->with('NewUser')->will($this->returnValue(false));
     $this->userManager->expects($this->once())->method('createUser')->with('NewUser', 'PasswordOfTheNewUser')->will($this->throwException(new \Exception('User backend not found.')));
     $this->logger->expects($this->once())->method('error')->with('Failed addUser attempt with exception: User backend not found.', ['app' => 'ocs_api']);
     $expected = new \OC_OCS_Result(null, 101, 'Bad request');
     $this->assertEquals($expected, $this->api->addUser());
 }
開發者ID:rajeshpillai,項目名稱:core,代碼行數:10,代碼來源:userstest.php

示例3: testGetApplicationDownloadParseError

 public function testGetApplicationDownloadParseError()
 {
     $this->config->expects($this->at(0))->method('getSystemValue')->with('appstoreenabled', true)->will($this->returnValue(true));
     $this->config->expects($this->at(1))->method('getSystemValue')->with('appstoreurl', 'https://api.owncloud.com/v1')->will($this->returnValue('https://api.owncloud.com/v1'));
     $response = $this->getMock('\\OCP\\Http\\Client\\IResponse');
     $response->expects($this->once())->method('getBody')->will($this->returnValue('MyInvalidXml'));
     $client = $this->getMock('\\OCP\\Http\\Client\\IClient');
     $client->expects($this->once())->method('get')->with('https://api.owncloud.com/v1/content/download/MyId/1', ['timeout' => 5, 'query' => ['version' => '8x1x0x7']])->will($this->returnValue($response));
     $this->clientService->expects($this->once())->method('newClient')->will($this->returnValue($client));
     $this->logger->expects($this->once())->method('error')->with('Could not get application download URL, content was no valid XML', ['app' => 'core']);
     $this->assertNull($this->ocsClient->getApplicationDownload('MyId', [8, 1, 0, 7]));
 }
開發者ID:evanjt,項目名稱:core,代碼行數:12,代碼來源:ocsclienttest.php

示例4: testGetCipherWithInvalidCipher

 public function testGetCipherWithInvalidCipher()
 {
     $this->config->expects($this->once())->method('getSystemValue')->with($this->equalTo('cipher'), $this->equalTo('AES-256-CTR'))->willReturn('Not-Existing-Cipher');
     $this->logger->expects($this->once())->method('warning')->with('Unsupported cipher (Not-Existing-Cipher) defined in config.php supported. Falling back to AES-256-CTR');
     $this->assertSame('AES-256-CTR', $this->crypt->getCipher());
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:6,代碼來源:CryptTest.php


注:本文中的OCP\ILogger::expects方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。