Exemplo n.º 1
0
 /**
  * @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 testBeforeExecute()
 {
     $logoutReasonCode = 2;
     $uri = '/uri/';
     $errorMessage = 'Error Message';
     $this->securityCookieHelperMock->expects($this->once())->method('getLogoutReasonCookie')->willReturn($logoutReasonCode);
     $this->backendControllerAuthLoginMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
     $this->requestMock->expects($this->once())->method('getUri')->willReturn($uri);
     $this->backendControllerAuthLoginMock->expects($this->once())->method('getUrl')->willReturn($uri);
     $this->adminSessionsManagerMock->expects($this->once())->method('getLogoutReasonMessageByStatus')->with($logoutReasonCode)->willReturn($errorMessage);
     $this->messageManagerMock->expects($this->once())->method('addError')->with($errorMessage);
     $this->securityCookieHelperMock->expects($this->once())->method('deleteLogoutReasonCookie')->willReturnSelf();
     $this->controller->beforeExecute($this->backendControllerAuthLoginMock);
 }
Exemplo n.º 3
0
 /**
  * @return void
  */
 public function testExecuteException()
 {
     $phrase = new \Magento\Framework\Phrase('We couldn\'t logout because of an error.');
     $this->sessionsManager->expects($this->once())->method('logoutOtherUserSessions')->willThrowException(new \Exception());
     $this->messageManager->expects($this->once())->method('addException')->with(new \Exception(), $phrase);
     $this->controller->execute();
 }
Exemplo n.º 4
0
 /**
  * @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));
 }
Exemplo n.º 5
0
 /**
  * @param bool $expectedResult
  * @param int $sessionsNumber
  * @dataProvider dataProviderAreMultipleSessionsActive
  */
 public function testAreMultipleSessionsActive($expectedResult, $sessionsNumber)
 {
     $this->sessionsManager->expects($this->once())->method('getSessionsForCurrentUser')->willReturn($this->collectionMock);
     $this->collectionMock->expects($this->any())->method('count')->willReturn($sessionsNumber);
     $this->assertEquals($expectedResult, $this->block->areMultipleSessionsActive());
 }
Exemplo n.º 6
0
 /**
  * @return void
  */
 public function testBeforeLogout()
 {
     $this->sessionsManager->expects($this->once())->method('processLogout');
     $this->model->beforeLogout($this->authMock);
 }