本文整理汇总了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());
}
示例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());
}
示例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]));
}
示例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());
}