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


PHP ISession::expects方法代码示例

本文整理汇总了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'));
 }
开发者ID:evanjt,项目名称:core,代码行数:9,代码来源:cryptowrappingtest.php

示例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('', '', ''));
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:7,代码来源:LoginControllerTest.php

示例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);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:12,代码来源:SessionTest.php

示例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);
 }
开发者ID:TechArea,项目名称:core,代码行数:11,代码来源:auth.php

示例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'));
 }
开发者ID:nem0xff,项目名称:core,代码行数:11,代码来源:auth.php

示例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);
 }
开发者ID:kebenxiaoming,项目名称:core,代码行数:13,代码来源:auth.php

示例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']);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:22,代码来源:SettingsControllerTest.php

示例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);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:9,代码来源:EnvCheckMiddlewareTest.php

示例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);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:6,代码来源:ManagerTest.php

示例10: testHasTokenWithoutExistingToken

 public function testHasTokenWithoutExistingToken()
 {
     $this->session->expects($this->once())->method('exists')->with('requesttoken')->willReturn(false);
     $this->assertSame(false, $this->sessionStorage->hasToken());
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:5,代码来源:SessionStorageTest.php


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