本文整理汇总了PHP中OCP\ISession::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP ISession::expects方法的具体用法?PHP ISession::expects怎么用?PHP ISession::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCP\ISession
的用法示例。
在下文中一共展示了ISession::expects方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUnwrappingGet
public function testUnwrappingGet()
{
$unencryptedValue = 'foobar';
$encryptedValue = $this->crypto->encrypt($unencryptedValue);
$this->wrappedSession->expects($this->once())->method('get')->with('encrypted_session_data')->willReturnCallback(function () use($encryptedValue) {
return $encryptedValue;
});
$this->assertSame($unencryptedValue, $this->wrappedSession->get('encrypted_session_data'));
}
示例2: testShowLoginFormWithErrorsInSession
public function testShowLoginFormWithErrorsInSession()
{
$this->userSession->expects($this->once())->method('isLoggedIn')->willReturn(false);
$this->session->expects($this->once())->method('get')->with('loginMessages')->willReturn([['ErrorArray1', 'ErrorArray2'], ['MessageArray1', 'MessageArray2']]);
$expectedResponse = new TemplateResponse('core', 'login', ['ErrorArray1' => true, 'ErrorArray2' => true, 'messages' => ['MessageArray1', 'MessageArray2'], 'loginName' => '', 'user_autofocus' => true, 'canResetPassword' => true, 'alt_login' => [], 'rememberLoginAllowed' => \OC_Util::rememberLoginAllowed(), 'rememberLoginState' => 0], 'guest');
$this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', '', ''));
}
示例3: setUp
/**
*
*/
protected function setUp()
{
parent::setUp();
$this->sessionMock = $this->getMock('OCP\\ISession');
$this->sessionMock->expects($this->any())->method('set')->will($this->returnCallback([$this, "setValueTester"]));
$this->sessionMock->expects($this->any())->method('get')->will($this->returnCallback([$this, "getValueTester"]));
$this->sessionMock->expects($this->any())->method('remove')->will($this->returnCallback([$this, "removeValueTester"]));
$this->instance = new Session($this->sessionMock);
}
示例4: testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjaxButUserIsStillLoggedIn
public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjaxButUserIsStillLoggedIn()
{
/** @var \Sabre\HTTP\RequestInterface $httpRequest */
$httpRequest = $this->getMockBuilder('\\Sabre\\HTTP\\RequestInterface')->disableOriginalConstructor()->getMock();
/** @var \Sabre\HTTP\ResponseInterface $httpResponse */
$httpResponse = $this->getMockBuilder('\\Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
$this->userSession->expects($this->any())->method('isLoggedIn')->will($this->returnValue(true));
$this->session->expects($this->once())->method('get')->with('AUTHENTICATED_TO_DAV_BACKEND')->will($this->returnValue('MyTestUser'));
$httpRequest->expects($this->once())->method('getHeader')->with('Authorization')->will($this->returnValue(null));
$this->auth->check($httpRequest, $httpResponse);
}
示例5: testAuthenticateAlreadyLoggedIn
public function testAuthenticateAlreadyLoggedIn()
{
$server = $this->getMockBuilder('\\Sabre\\DAV\\Server')->disableOriginalConstructor()->getMock();
$this->userSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true));
$this->session->expects($this->once())->method('get')->with('AUTHENTICATED_TO_DAV_BACKEND')->will($this->returnValue(null));
$user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
$user->expects($this->once())->method('getUID')->will($this->returnValue('MyWrongDavUser'));
$this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($user));
$this->session->expects($this->once())->method('close');
$this->assertTrue($this->auth->authenticate($server, 'TestRealm'));
}
示例6: testAuthenticateAlreadyLoggedIn
public function testAuthenticateAlreadyLoggedIn()
{
$request = $this->getMockBuilder('Sabre\\HTTP\\RequestInterface')->disableOriginalConstructor()->getMock();
$response = $this->getMockBuilder('Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
$this->userSession->expects($this->once())->method('isLoggedIn')->will($this->returnValue(true));
$this->session->expects($this->once())->method('get')->with('AUTHENTICATED_TO_DAV_BACKEND')->will($this->returnValue(null));
$user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
$user->expects($this->once())->method('getUID')->will($this->returnValue('MyWrongDavUser'));
$this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($user));
$this->session->expects($this->once())->method('close');
$response = $this->auth->check($request, $response);
$this->assertEquals([true, 'principals/users/MyWrongDavUser'], $response);
}
示例7: 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']);
}
示例8: mockSessionWithLinkItemId
/**
* Mocks ISession->get('public_link_authenticated')
*
* @param int $linkItemId
*/
private function mockSessionWithLinkItemId($linkItemId)
{
$this->session->expects($this->once())->method('get')->with('public_link_authenticated')->willReturn($linkItemId);
}
示例9: testPrepareTwoFactorLogin
public function testPrepareTwoFactorLogin()
{
$this->user->expects($this->once())->method('getUID')->will($this->returnValue('ferdinand'));
$this->session->expects($this->once())->method('set')->with('two_factor_auth_uid', 'ferdinand');
$this->manager->prepareTwoFactorLogin($this->user);
}
示例10: testHasTokenWithoutExistingToken
public function testHasTokenWithoutExistingToken()
{
$this->session->expects($this->once())->method('exists')->with('requesttoken')->willReturn(false);
$this->assertSame(false, $this->sessionStorage->hasToken());
}