32 lines
797 B
PHP
32 lines
797 B
PHP
<?php
|
|
|
|
namespace Tests\Feature\Models;
|
|
|
|
use App\Models\OtpCode;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Carbon;
|
|
use Tests\TestCase;
|
|
|
|
class OtpCodeTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_is_expired_is_false_before_expiry(): void
|
|
{
|
|
$this->assertFalse(OtpCode::factory()->create()->isExpired());
|
|
}
|
|
|
|
public function test_is_expired_is_true_after_expiry(): void
|
|
{
|
|
$this->assertTrue(OtpCode::factory()->expired()->create()->isExpired());
|
|
}
|
|
|
|
public function test_is_expired_is_false_at_exact_expiry_moment(): void
|
|
{
|
|
Carbon::setTestNow('2026-09-21 10:00:00');
|
|
$otp = OtpCode::factory()->create(['expires_at' => now()]);
|
|
|
|
$this->assertFalse($otp->isExpired());
|
|
}
|
|
}
|