/** * @return \Magento\Security\Model\ResourceModel\AdminSessionInfo\Collection */ public function getSessionInfoCollection() { if (null === $this->sessionsInfoCollection) { $this->sessionsInfoCollection = $this->sessionsManager->getSessionsForCurrentUser(); } return $this->sessionsInfoCollection; }
/** * @return void */ public function testGetSessionsForCurrentUser() { $useId = 1; $sessionLifetime = 100; $this->adminSessionInfoCollectionFactoryMock->expects($this->once())->method('create')->willReturn($this->adminSessionInfoCollectionMock); $this->authSessionMock->expects($this->once())->method('getUser')->willReturn($this->userMock); $this->userMock->expects($this->once())->method('getId')->willReturn($useId); $this->adminSessionInfoCollectionMock->expects($this->once())->method('filterByUser')->with($useId, \Magento\Security\Model\AdminSessionInfo::LOGGED_IN)->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->assertSame($this->adminSessionInfoCollectionMock, $this->model->getSessionsForCurrentUser()); }