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


PHP Session::expects方法代码示例

本文整理汇总了PHP中Magento\Backend\Model\Auth\Session::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::expects方法的具体用法?PHP Session::expects怎么用?PHP Session::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Backend\Model\Auth\Session的用法示例。


在下文中一共展示了Session::expects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 protected function setUp()
 {
     $this->_session = $this->getMock('Magento\\Backend\\Model\\Session', [], [], '', false);
     $this->_authSession = $this->getMock('Magento\\Backend\\Model\\Auth\\Session', ['getUser'], [], '', false);
     $userMock = new \Magento\Framework\Object();
     $this->_authSession->expects($this->any())->method('getUser')->will($this->returnValue($userMock));
     $this->_translator = $this->getMock('Magento\\Framework\\TranslateInterface', [], [], '', false);
     $this->_translator->expects($this->any())->method('setLocale')->will($this->returnValue($this->_translator));
     $this->_translator->expects($this->any())->method('init')->will($this->returnValue(false));
     $this->_model = new \Magento\Backend\Model\Locale\Manager($this->_session, $this->_authSession, $this->_translator);
 }
开发者ID:opexsw,项目名称:magento2,代码行数:11,代码来源:ManagerTest.php

示例2: testReportConcurrentAdminsToNewRelic

 /**
  * Test case when module is enabled and user is logged in
  *
  * @return void
  */
 public function testReportConcurrentAdminsToNewRelic()
 {
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $this->backendAuthSession->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->getMock();
     $this->backendAuthSession->expects($this->once())->method('getUser')->willReturn($userMock);
     $this->newRelicWrapper->expects($this->exactly(3))->method('addCustomParameter')->willReturn(true);
     $this->model->execute($eventObserver);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:16,代码来源:ReportConcurrentAdminsToNewRelicTest.php

示例3: testReportSystemCacheFlushToNewRelic

 /**
  * Test case when module is enabled in config
  *
  * @return void
  */
 public function testReportSystemCacheFlushToNewRelic()
 {
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->getMock();
     $this->backendAuthSession->expects($this->once())->method('getUser')->willReturn($userMock);
     $userMock->expects($this->once())->method('getId')->willReturn('2');
     $this->deploymentsFactory->expects($this->once())->method('create')->willReturn($this->deploymentsModel);
     $this->deploymentsModel->expects($this->once())->method('setDeployment')->willReturnSelf();
     $this->model->execute($eventObserver);
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:ReportSystemCacheFlushToNewRelicTest.php

示例4: testAroundProlongSessionIsNotActiveAndIsAjaxRequest

 /**
  * @return void
  */
 public function testAroundProlongSessionIsNotActiveAndIsAjaxRequest()
 {
     $result = 'result';
     $status = 1;
     $proceed = function () use($result) {
         return $result;
     };
     $this->currentSessionMock->expects($this->any())->method('isActive')->willReturn(false);
     $this->authSessionMock->expects($this->once())->method('destroy');
     $this->requestMock->expects($this->once())->method('getParam')->with('isAjax')->willReturn(true);
     $this->currentSessionMock->expects($this->once())->method('getStatus')->willReturn($status);
     $this->securityCookieMock->expects($this->once())->method('setLogoutReasonCookie')->with($status)->willReturnSelf();
     $this->model->aroundProlong($this->authSessionMock, $proceed);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:17,代码来源:AuthSessionTest.php

示例5: testAdminAuthenticate

 public function testAdminAuthenticate()
 {
     $password = "myP@sw0rd";
     $uid = 123;
     $authResult = true;
     $lockExpires = false;
     $userPassword = ['expires' => 1];
     /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getPassword', 'getUser', 'getResult'])->getMock();
     /** @var ModelUser|\PHPUnit_Framework_MockObject_MockObject $userMock */
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getLockExpires', 'getPassword', 'save'])->getMock();
     $eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
     $eventMock->expects($this->once())->method('getPassword')->willReturn($password);
     $eventMock->expects($this->once())->method('getUser')->willReturn($userMock);
     $eventMock->expects($this->once())->method('getResult')->willReturn($authResult);
     $userMock->expects($this->atLeastOnce())->method('getId')->willReturn($uid);
     $userMock->expects($this->once())->method('getLockExpires')->willReturn($lockExpires);
     $this->userMock->expects($this->once())->method('unlock');
     $this->userMock->expects($this->once())->method('getLatestPassword')->willReturn($userPassword);
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     /** @var Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
     $collectionMock = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->managerInterfaceMock->expects($this->once())->method('getMessages')->willReturn($collectionMock);
     $collectionMock->expects($this->once())->method('getLastAddedMessage')->willReturn($this->messageInterfaceMock);
     $this->messageInterfaceMock->expects($this->once())->method('setIdentifier')->willReturnSelf();
     $this->authSessionMock->expects($this->once())->method('setPciAdminUserIsPasswordExpired');
     $this->encryptorMock->expects($this->once())->method('validateHashVersion')->willReturn(false);
     $this->model->execute($eventObserverMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:31,代码来源:AuthObserverTest.php

示例6: setUp

 protected function setUp()
 {
     $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->_group = $this->getMock('Magento\\Config\\Model\\Config\\Structure\\Element\\Group', [], [], '', false);
     $this->_element = $this->getMockForAbstractClass('Magento\\Framework\\Data\\Form\\Element\\AbstractElement', [], '', false, true, true, ['getHtmlId', 'getElementHtml', 'getName', 'getElements', 'getId']);
     $this->_element->expects($this->any())->method('getHtmlId')->will($this->returnValue('html id'));
     $this->_element->expects($this->any())->method('getElementHtml')->will($this->returnValue('element html'));
     $this->_element->expects($this->any())->method('getName')->will($this->returnValue('name'));
     $this->_element->expects($this->any())->method('getElements')->will($this->returnValue([]));
     $this->_element->expects($this->any())->method('getId')->will($this->returnValue('id'));
     $this->_user = $this->getMock('Magento\\User\\Model\\User', [], [], '', false);
     $this->_authSession = $this->getMock('Magento\\Backend\\Model\\Auth\\Session', [], [], '', false);
     $this->_authSession->expects($this->any())->method('__call')->with('getUser')->will($this->returnValue($this->_user));
     $this->_model = $helper->getObject('Magento\\Paypal\\Block\\Adminhtml\\System\\Config\\Fieldset\\Group', ['authSession' => $this->_authSession]);
     $this->_model->setGroup($this->_group);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:GroupTest.php

示例7: testSaveAction

 public function testSaveAction()
 {
     $userId = 1;
     $requestParams = ['password' => 'password', 'password_confirmation' => true, 'interface_locale' => 'US', 'username' => 'Foo', 'firstname' => 'Bar', 'lastname' => 'Dummy', 'email' => 'test@example.com', \Magento\Backend\Block\System\Account\Edit\Form::IDENTITY_VERIFICATION_PASSWORD_FIELD => 'current_password'];
     $testedMessage = 'You saved the account.';
     $this->_authSessionMock->expects($this->any())->method('getUser')->will($this->returnValue($this->_userMock));
     $this->_userMock->expects($this->any())->method('load')->will($this->returnSelf());
     $this->_validatorMock->expects($this->once())->method('isValid')->with($this->equalTo($requestParams['interface_locale']))->will($this->returnValue(true));
     $this->_managerMock->expects($this->any())->method('switchBackendInterfaceLocale');
     $this->_objectManagerMock->expects($this->at(0))->method('get')->with($this->equalTo('Magento\\Backend\\Model\\Auth\\Session'))->will($this->returnValue($this->_authSessionMock));
     $this->_objectManagerMock->expects($this->at(1))->method('create')->with($this->equalTo('Magento\\User\\Model\\User'))->will($this->returnValue($this->_userMock));
     $this->_objectManagerMock->expects($this->at(2))->method('get')->with($this->equalTo('Magento\\Framework\\Validator\\Locale'))->will($this->returnValue($this->_validatorMock));
     $this->_objectManagerMock->expects($this->at(3))->method('get')->with($this->equalTo('Magento\\Backend\\Model\\Locale\\Manager'))->will($this->returnValue($this->_managerMock));
     $this->_userMock->setUserId($userId);
     $this->_userMock->expects($this->once())->method('save');
     $this->_userMock->expects($this->once())->method('verifyIdentity')->will($this->returnValue(true));
     $this->_userMock->expects($this->once())->method('sendPasswordResetNotificationEmail');
     $this->_requestMock->setParams($requestParams);
     $this->_messagesMock->expects($this->once())->method('addSuccess')->with($this->equalTo($testedMessage));
     $this->_controller->execute();
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:21,代码来源:SaveTest.php

示例8: testTrackAdminPassword

 public function testTrackAdminPassword()
 {
     $newPW = "mYn3wpassw0rd";
     $uid = 123;
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getObject'])->getMock();
     /** @var \Magento\User\Model\User|\PHPUnit_Framework_MockObject_MockObject $userMock */
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->setMethods(['getId', 'getPassword', 'getForceNewPassword'])->getMock();
     $eventObserverMock->expects($this->once())->method('getEvent')->willReturn($eventMock);
     $eventMock->expects($this->once())->method('getObject')->willReturn($userMock);
     $userMock->expects($this->once())->method('getId')->willReturn($uid);
     $userMock->expects($this->once())->method('getPassword')->willReturn($newPW);
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     $userMock->expects($this->once())->method('getForceNewPassword')->willReturn(false);
     /** @var \Magento\Framework\Message\Collection|\PHPUnit_Framework_MockObject_MockObject $collectionMock */
     $collectionMock = $this->getMockBuilder('Magento\\Framework\\Message\\Collection')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->managerInterfaceMock->expects($this->once())->method('getMessages')->willReturn($collectionMock);
     $this->authSessionMock->expects($this->once())->method('unsPciAdminUserIsPasswordExpired')->willReturn(null);
     $this->model->execute($eventObserverMock);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:22,代码来源:TrackAdminNewPasswordObserverTest.php

示例9: testReportConcurrentAdmins

 /**
  * Test case when module is enabled and user is logged in
  *
  * @return void
  */
 public function testReportConcurrentAdmins()
 {
     $testAction = 'JSON string';
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserver */
     $eventObserver = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->getMock();
     $this->config->expects($this->once())->method('isNewRelicEnabled')->willReturn(true);
     $this->backendAuthSession->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $userMock = $this->getMockBuilder('Magento\\User\\Model\\User')->disableOriginalConstructor()->getMock();
     $this->backendAuthSession->expects($this->once())->method('getUser')->willReturn($userMock);
     $this->jsonEncoder->expects($this->once())->method('encode')->willReturn($testAction);
     $this->usersModel->expects($this->once())->method('setData')->with(['type' => 'admin_activity', 'action' => $testAction])->willReturnSelf();
     $this->usersModel->expects($this->once())->method('save');
     $this->model->execute($eventObserver);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:ReportConcurrentAdminsTest.php

示例10: testForceAdminPasswordChange

 public function testForceAdminPasswordChange()
 {
     /** @var \Magento\Framework\Event\Observer|\PHPUnit_Framework_MockObject_MockObject $eventObserverMock */
     $eventObserverMock = $this->getMockBuilder('Magento\\Framework\\Event\\Observer')->disableOriginalConstructor()->setMethods([])->getMock();
     /** @var \Magento\Framework\Event|\PHPUnit_Framework_MockObject_MockObject */
     $eventMock = $this->getMockBuilder('Magento\\Framework\\Event')->disableOriginalConstructor()->setMethods(['getControllerAction', 'getRequest'])->getMock();
     $this->configInterfaceMock->expects($this->atLeastOnce())->method('getValue')->willReturn(1);
     $this->authSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(true);
     $eventObserverMock->expects($this->atLeastOnce())->method('getEvent')->willReturn($eventMock);
     /** @var \Magento\Framework\App\Action\Action $controllerMock */
     $controllerMock = $this->getMockBuilder('Magento\\Framework\\App\\Action\\AbstractAction')->disableOriginalConstructor()->setMethods(['getRedirect', 'getRequest'])->getMockForAbstractClass();
     /** @var \Magento\Framework\App\RequestInterface $requestMock */
     $requestMock = $this->getMockBuilder('Magento\\Framework\\App\\RequestInterface')->disableOriginalConstructor()->setMethods(['getFullActionName', 'setDispatched'])->getMockForAbstractClass();
     $eventMock->expects($this->once())->method('getControllerAction')->willReturn($controllerMock);
     $eventMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $this->authSessionMock->expects($this->once())->method('getPciAdminUserIsPasswordExpired')->willReturn(true);
     $requestMock->expects($this->once())->method('getFullActionName')->willReturn('not_in_array');
     $this->authSessionMock->expects($this->once())->method('clearStorage');
     $this->sessionMock->expects($this->once())->method('clearStorage');
     $this->managerInterfaceMock->expects($this->once())->method('addErrorMessage');
     $controllerMock->expects($this->once())->method('getRequest')->willReturn($requestMock);
     $requestMock->expects($this->once())->method('setDispatched')->willReturn(false);
     $this->model->execute($eventObserverMock);
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:24,代码来源:ForceAdminPasswordChangeObserverTest.php

示例11: testLogoutOtherUserSessions

 /**
  * @return void
  */
 public function testLogoutOtherUserSessions()
 {
     $useId = 1;
     $sessionLifetime = 100;
     $sessionId = 50;
     $this->adminSessionInfoCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->adminSessionInfoCollectionMock);
     $this->authSessionMock->expects($this->once())->method('getUser')->willReturn($this->userMock);
     $this->authSessionMock->expects($this->once())->method('getSessionId')->willReturn($sessionId);
     $this->userMock->expects($this->once())->method('getId')->willReturn($useId);
     $this->adminSessionInfoCollectionMock->expects($this->once())->method('filterByUser')->with($useId, \Magento\Security\Model\AdminSessionInfo::LOGGED_IN, $sessionId)->willReturnSelf();
     $this->securityConfigMock->expects($this->once())->method('getAdminSessionLifetime')->willReturn($sessionLifetime);
     $this->adminSessionInfoCollectionMock->expects($this->once())->method('filterExpiredSessions')->with($sessionLifetime)->willReturnSelf();
     $this->adminSessionInfoCollectionMock->expects($this->once())->method('loadData')->willReturnSelf();
     $this->adminSessionInfoCollectionMock->expects($this->once())->method('setDataToAll')->with($this->equalTo('status'), \Magento\Security\Model\AdminSessionInfo::LOGGED_OUT_MANUALLY)->willReturnSelf();
     $this->adminSessionInfoCollectionMock->expects($this->once())->method('save');
     $this->model->logoutOtherUserSessions();
 }
开发者ID:dragonsword007008,项目名称:magento2,代码行数:20,代码来源:AdminSessionsManagerTest.php


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