feat: add comprehensive tests for Medium, OtpCode, Shift models and various Enums
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user