Skip to content

Commit f5a713b

Browse files
committed
test(models): 优化模型测试用例并添加 AuthenticationLog 模型测试
- 添加 AuthenticationLog 模型的单元测试 - 优化 Ip、RequestLog 和 User 模型测试用例的变量命名- 调整 User 模型测试用例的数组顺序
1 parent d991dd9 commit f5a713b

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Models\AuthenticationLog;
6+
7+
test('to array', function () {
8+
$authenticationLog = AuthenticationLog::factory()->create()->fresh();
9+
10+
expect(array_keys($authenticationLog->toArray()))
11+
->toBe([
12+
'id',
13+
'user_id',
14+
'ip_address',
15+
'user_agent',
16+
'successful',
17+
'created_at',
18+
'updated_at',
19+
]);
20+
});

tests/Unit/Models/IpTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
use App\Models\Ip;
66

77
test('to array', function () {
8-
$user = Ip::factory()->create()->fresh();
8+
$ip = Ip::factory()->create()->fresh();
99

10-
expect(array_keys($user->toArray()))
10+
expect(array_keys($ip->toArray()))
1111
->toBe([
1212
'id',
1313
'address',

tests/Unit/Models/RequestLogTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
use App\Models\RequestLog;
66

77
test('to array', function () {
8-
$user = RequestLog::factory()->create()->fresh();
8+
$requestLog = RequestLog::factory()->create()->fresh();
99

10-
expect(array_keys($user->toArray()))
10+
expect(array_keys($requestLog->toArray()))
1111
->toBe([
1212
'id',
1313
'uuid',

tests/Unit/Models/UserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
'nickname',
1616
'role',
1717
'mobile',
18-
'mobile_verified_at',
1918
'email',
20-
'email_verified_at',
2119
'timezone',
2220
'status',
21+
'mobile_verified_at',
22+
'email_verified_at',
2323
'created_at',
2424
'updated_at',
2525
'deleted_at',

0 commit comments

Comments
 (0)