feature: change password

This commit is contained in:
antv
2026-07-08 13:03:48 +07:00
parent 63764d0718
commit 6056e33ef8
16 changed files with 371 additions and 56 deletions
+61 -13
View File
@@ -202,13 +202,13 @@ class AdminUserListStatsTest extends TestCase
$this->assertEquals(2002, $users2->items()[0]->msnv);
}
public function test_user_list_stats_filters_by_flag_send(): void
public function test_user_list_stats_filters_by_status(): void
{
// 1. Create mock users
User::create([
'msnv' => 3001,
'name' => 'DEV ENABLED',
'mail' => 'enabled@example.com',
'name' => 'DEV ACTIVE',
'mail' => 'active@example.com',
'pass' => md5('password'),
'departments' => 1,
'role' => User::ROLE_MEMBER,
@@ -220,27 +220,75 @@ class AdminUserListStatsTest extends TestCase
User::create([
'msnv' => 3002,
'name' => 'DEV DISABLED',
'mail' => 'disabled@example.com',
'name' => 'DEV INACTIVE',
'mail' => 'inactive@example.com',
'pass' => md5('password'),
'departments' => 1,
'role' => User::ROLE_MEMBER,
'status' => User::STATUS_INACTIVE,
'card' => 10,
'flag_send' => User::FLAG_SEND_DISABLED,
'first_login' => User::FIRST_LOGIN_FALSE,
]);
// 2. Fetch statistics via AdminService with status = '1'
$stats = $this->adminService->getUserListWithStats('2026-07', null, '1');
$users = collect($stats['users']->items());
$this->assertTrue($users->contains('msnv', 3001));
$this->assertFalse($users->contains('msnv', 3002));
// 3. Fetch statistics via AdminService with status = '0'
$stats2 = $this->adminService->getUserListWithStats('2026-07', null, '0');
$users2 = collect($stats2['users']->items());
$this->assertTrue($users2->contains('msnv', 3002));
$this->assertFalse($users2->contains('msnv', 3001));
}
public function test_user_list_stats_filters_by_role_department_and_flag_send(): void
{
// 1. Create mock users
User::create([
'msnv' => 4001,
'name' => 'ADMIN DEV ENABLED',
'mail' => 'admin_dev@example.com',
'pass' => md5('password'),
'departments' => 1,
'role' => User::ROLE_ADMIN,
'status' => User::STATUS_ACTIVE,
'card' => 10,
'flag_send' => User::FLAG_SEND_ENABLED,
'first_login' => User::FIRST_LOGIN_FALSE,
]);
User::create([
'msnv' => 4002,
'name' => 'MEMBER HR DISABLED',
'mail' => 'member_hr@example.com',
'pass' => md5('password'),
'departments' => 2,
'role' => User::ROLE_MEMBER,
'status' => User::STATUS_ACTIVE,
'card' => 10,
'flag_send' => User::FLAG_SEND_DISABLED,
'first_login' => User::FIRST_LOGIN_FALSE,
]);
// 2. Fetch statistics via AdminService with flag_send = '1'
$stats = $this->adminService->getUserListWithStats('2026-07', null, '1');
// Filter by role = Admin ('1')
$stats = $this->adminService->getUserListWithStats('2026-07', null, '1', '1');
$users = collect($stats['users']->items());
$this->assertTrue($users->contains('msnv', 3001));
$this->assertFalse($users->contains('msnv', 3002));
$this->assertTrue($users->contains('msnv', 4001));
$this->assertFalse($users->contains('msnv', 4002));
// 3. Fetch statistics via AdminService with flag_send = '0'
$stats2 = $this->adminService->getUserListWithStats('2026-07', null, '0');
// Filter by department = HR ('2')
$stats2 = $this->adminService->getUserListWithStats('2026-07', null, '1', null, '2');
$users2 = collect($stats2['users']->items());
$this->assertTrue($users2->contains('msnv', 3002));
$this->assertFalse($users2->contains('msnv', 3001));
$this->assertTrue($users2->contains('msnv', 4002));
$this->assertFalse($users2->contains('msnv', 4001));
// Filter by flag_send = Enabled ('1')
$stats3 = $this->adminService->getUserListWithStats('2026-07', null, '1', null, null, '1');
$users3 = collect($stats3['users']->items());
$this->assertTrue($users3->contains('msnv', 4001));
$this->assertFalse($users3->contains('msnv', 4002));
}
}