userManager = $this->createMock(IUserManager::class); $this->logger = $this->createMock(LoggerInterface::class); $this->cmd = new UserDisabledCheckCommand( $this->userManager, $this->logger ); } public function testProcessNonExistingUser() { $data = $this->getBasicLoginData(); $this->userManager->expects($this->once()) ->method('get') ->with($this->username) ->willReturn(null); $result = $this->cmd->process($data); $this->assertTrue($result->isSuccess()); } public function testProcessDisabledUser() { $data = $this->getBasicLoginData(); $this->userManager->expects($this->once()) ->method('get') ->with($this->username) ->willReturn($this->user); $this->user->expects($this->once()) ->method('isEnabled') ->willReturn(false); $result = $this->cmd->process($data); $this->assertFalse($result->isSuccess()); $this->assertSame(LoginController::LOGIN_MSG_USERDISABLED, $result->getErrorMessage()); } public function testProcess() { $data = $this->getBasicLoginData(); $this->userManager->expects($this->once()) ->method('get') ->with($this->username) ->willReturn($this->user); $this->user->expects($this->once()) ->method('isEnabled') ->willReturn(true); $result = $this->cmd->process($data); $this->assertTrue($result->isSuccess()); } }