Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/VerificationCodeTest.php
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | public function testVerificationCodeCreate(): void | ||||
$code_exp_hrs = env('VERIFICATION_CODE_EXPIRY', VerificationCode::CODE_EXP_HOURS); | $code_exp_hrs = env('VERIFICATION_CODE_EXPIRY', VerificationCode::CODE_EXP_HOURS); | ||||
$this->assertFalse($code->isExpired()); | $this->assertFalse($code->isExpired()); | ||||
$this->assertTrue(strlen($code->code) === VerificationCode::CODE_LENGTH); | $this->assertTrue(strlen($code->code) === VerificationCode::CODE_LENGTH); | ||||
$this->assertTrue(strlen($code->short_code) === $code_length); | $this->assertTrue(strlen($code->short_code) === $code_length); | ||||
$this->assertSame($data['mode'], $code->mode); | $this->assertSame($data['mode'], $code->mode); | ||||
$this->assertEquals($user->id, $code->user->id); | $this->assertEquals($user->id, $code->user->id); | ||||
$this->assertInstanceOf(\DateTime::class, $code->expires_at); | $this->assertInstanceOf(\DateTime::class, $code->expires_at); | ||||
$this->assertSame($code_exp_hrs, $code->expires_at->diff($now)->h + 1); | $this->assertSame($code_exp_hrs, $code->expires_at->diff($now)->h + 1); | ||||
$inst = VerificationCode::find($code->code); | $inst = VerificationCode::find($code->code); | ||||
$this->assertInstanceOf(VerificationCode::class, $inst); | $this->assertInstanceOf(VerificationCode::class, $inst); | ||||
$this->assertSame($inst->code, $code->code); | $this->assertSame($inst->code, $code->code); | ||||
} | } | ||||
} | } |