74 $this->sessionsInfoCollection = $this->createPartialMock(
79 $this->sessionsManager = $this->createPartialMock(
80 \
Magento\Security\Model\AdminSessionsManager::class,
81 [
'getSessionsForCurrentUser']
84 $this->securityConfig = $this->getMockBuilder(\
Magento\Security\Model\ConfigInterface::class)
85 ->disableOriginalConstructor()
88 $this->sessionMock = $this->createMock(\
Magento\Security\Model\AdminSessionInfo::class);
90 $this->localeDate = $this->getMockForAbstractClass(
91 \
Magento\Framework\Stdlib\DateTime\TimezoneInterface::class,
97 $this->collectionMock = $this->createPartialMock(
102 $this->remoteAddressMock = $this->getMockBuilder(RemoteAddress::class)
103 ->disableOriginalConstructor()
106 $this->block = $this->objectManager->getObject(
107 \
Magento\Security\Block\Adminhtml\Session\Activity::class,
109 'sessionsManager' => $this->sessionsManager,
110 'securityConfig' => $this->securityConfig,
111 'localeDate' => $this->localeDate,
112 'remoteAddress' => $this->remoteAddressMock
122 $this->sessionsManager->expects($this->once())
123 ->method(
'getSessionsForCurrentUser')
124 ->willReturn($this->collectionMock);
125 $this->assertInstanceOf(
127 $this->block->getSessionInfoCollection()
138 $this->sessionsManager->expects($this->once())
139 ->method(
'getSessionsForCurrentUser')
140 ->willReturn($this->collectionMock);
141 $this->collectionMock->expects($this->any())
143 ->willReturn($sessionsNumber);
144 $this->assertEquals($expectedResult, $this->block->areMultipleSessionsActive());
153 [
'expectedResult' =>
false,
'sessionsNumber' => 0],
154 [
'expectedResult' =>
false,
'sessionsNumber' => 1],
155 [
'expectedResult' =>
true,
'sessionsNumber' => 2],
164 $this->remoteAddressMock->expects($this->once())
165 ->method(
'getRemoteAddress')
167 $this->block->getRemoteIp();
176 $time = new \DateTime($timeString);
177 $this->localeDate->expects($this->any())
178 ->method(
'formatDateTime')
179 ->with($time, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::MEDIUM)
181 $this->assertEquals($time, $this->block->formatDateTime($timeString));
190 [
'timeString' =>
'2015-12-28 13:00:00'],
191 [
'timeString' =>
'2015-12-23 01:10:37']
testFormatDateTime($timeString)
testSessionInfoCollectionIsEmpty()
testAreMultipleSessionsActive($expectedResult, $sessionsNumber)
dataProviderAreMultipleSessionsActive()