/** * @return void */ public function testAfterLogin() { $warningMessage = __('All other open sessions for this account were terminated.'); $this->sessionsManager->expects($this->once())->method('processLogin'); $this->sessionsManager->expects($this->once())->method('getCurrentSession')->willReturn($this->currentSession); $this->currentSession->expects($this->once())->method('isOtherSessionsTerminated')->willReturn(true); $this->messageManager->expects($this->once())->method('addWarning')->with($warningMessage); $this->model->afterLogin($this->authMock); }
/** * @param bool $result * @dataProvider dataProviderTestExecute */ public function testExecute($result) { $resultExpectation = ['isActive' => $result]; $jsonMock = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->getMock(); $this->sessionsManager->expects($this->any())->method('getCurrentSession')->willReturn($this->currentSession); $this->currentSession->expects($this->any())->method('isActive')->will($this->returnValue($result)); $this->jsonFactory->expects($this->any())->method('create')->willReturn($jsonMock); $jsonMock->expects($this->once())->method('setData')->with($resultExpectation)->willReturnSelf(); $this->assertEquals($jsonMock, $this->controller->execute()); }
/** * @return void */ public function testAroundProlongSessionIsActive() { $result = 'result'; $proceed = function () use($result) { return $result; }; $this->currentSessionMock->expects($this->any())->method('isLoggedInStatus')->willReturn(true); $this->adminSessionsManagerMock->expects($this->any())->method('processProlong'); $this->assertEquals($result, $this->model->aroundProlong($this->authSessionMock, $proceed)); }
/** * @param string $expectedResult * @param int $sessionStatus * @dataProvider dataProviderLogoutReasonMessage */ public function testGetLogoutReasonMessage($expectedResult, $sessionStatus) { $this->adminSessionInfoFactoryMock->expects($this->once())->method('create')->willReturn($this->currentSessionMock); $this->currentSessionMock->expects($this->once())->method('getStatus')->will($this->returnValue($sessionStatus)); $this->assertEquals($expectedResult, $this->model->getLogoutReasonMessage()); }