public function testIsLoginLimitReached() { $maxLoginAttempts = 3; $user = $this->getMockBuilder('\\pmill\\Auth\\Interfaces\\AuthUser')->getMock(); $user->method('getAuthId')->willReturn(1); $user->method('getAuthPassword')->willReturn($this->correctHashedPassword); $auth = new \pmill\Auth\Authenticate(); $auth->setMaxAttempts($maxLoginAttempts); $auth->resetLoginAttempts(); for ($i = 1; $i <= $maxLoginAttempts + 1; $i++) { try { $auth->login($user, 'incorrect-password'); } catch (\pmill\Auth\Exceptions\PasswordException $e) { if ($i <= $maxLoginAttempts) { $this->assertEquals($i, $auth->getLoginAttempts()); $this->assertFalse($auth->isLoginLimitReached()); } else { $this->assertEquals($maxLoginAttempts + 1, $auth->getLoginAttempts()); $this->assertTrue($auth->isLoginLimitReached()); } } } }