otp_secret = 'some secret'; $controlTotp = new TOTP(null, 'some secret'); $validator = new TotpValidator(['account' => $account]); $result = $this->callProtected($validator, 'validateValue', 123456); $this->assertEquals([E::OTP_TOKEN_INCORRECT, []], $result); $result = $this->callProtected($validator, 'validateValue', $controlTotp->now()); $this->assertNull($result); $result = $this->callProtected($validator, 'validateValue', $controlTotp->at(time() - 31)); $this->assertEquals([E::OTP_TOKEN_INCORRECT, []], $result); $validator->window = 60; $result = $this->callProtected($validator, 'validateValue', $controlTotp->at(time() - 31)); $this->assertNull($result); } }