Exemplo n.º 1
0
 /**
  * @param \Magento\Backend\Model\Auth $authModel
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterLogin(\Magento\Backend\Model\Auth $authModel)
 {
     $this->sessionsManager->processLogin();
     if ($this->sessionsManager->getCurrentSession()->isOtherSessionsTerminated()) {
         $this->messageManager->addWarning(__('All other open sessions for this account were terminated.'));
     }
 }
 /**
  * @return void
  */
 public function testProcessLogin()
 {
     $useId = 1;
     $sessionLifetime = 100;
     $ip = 12345;
     $sessionId = 50;
     $timestamp = time();
     $olderThen = $timestamp - $sessionLifetime;
     $this->adminSessionInfoFactoryMock->expects($this->exactly(2))->method('create')->willReturn($this->currentSessionMock);
     $this->authSessionMock->expects($this->exactly(2))->method('getSessionId')->willReturn($sessionId);
     $this->authSessionMock->expects($this->once())->method('getUser')->willReturn($this->userMock);
     $this->userMock->expects($this->once())->method('getId')->willReturn($useId);
     $this->securityConfigMock->expects($this->once())->method('getRemoteIp')->willReturn($ip);
     $this->currentSessionMock->expects($this->once())->method('setData')->willReturnSelf();
     $this->currentSessionMock->expects($this->once())->method('save')->willReturnSelf();
     $this->securityConfigMock->method('getCurrentTimestamp')->willReturn($timestamp);
     $this->securityConfigMock->expects($this->once())->method('getAdminSessionLifetime')->willReturn($sessionLifetime);
     $this->securityConfigMock->expects($this->once())->method('isAdminAccountSharingEnabled')->willReturn(0);
     $this->currentSessionMock->expects($this->once())->method('getUserId')->willReturn($useId);
     $this->currentSessionMock->expects($this->once())->method('getSessionId')->willReturn($sessionId);
     $this->adminSessionInfoCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->adminSessionInfoCollectionMock);
     $this->adminSessionInfoCollectionMock->expects($this->once())->method('updateActiveSessionsStatus')->with(\Magento\Security\Model\AdminSessionInfo::LOGGED_OUT_BY_LOGIN, $useId, $sessionId, $olderThen)->willReturn(1);
     $this->currentSessionMock->expects($this->once())->method('setIsOtherSessionsTerminated')->with(true)->willReturnSelf();
     $this->model->processLogin();
 }