當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。