update P15
This commit is contained in:
@@ -201,6 +201,31 @@ class UserControllerTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function test_list_users_filter_by_role_id(): void
|
||||
{
|
||||
$admin_role = $this->fetchAdminRole();
|
||||
|
||||
$response = $this->get('/api/v1/users', ['role_id' => $admin_role->id], $this->authHeaders());
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonPath('code', 0);
|
||||
|
||||
$body = json_decode($response->getContent(), true);
|
||||
$this->assertGreaterThanOrEqual(1, $body['data']['total']);
|
||||
foreach ($body['data']['items'] as $item) {
|
||||
$this->assertSame($admin_role->id, $item['role_id']);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_list_users_filter_by_role_id_empty(): void
|
||||
{
|
||||
$response = $this->get('/api/v1/users', ['role_id' => 999999], $this->authHeaders());
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertJsonPath('code', 0);
|
||||
$response->assertJsonPath('data.total', 0);
|
||||
}
|
||||
|
||||
// ========== 详情接口测试 ==========
|
||||
|
||||
public function test_show_user_returns_user_data(): void
|
||||
|
||||
Reference in New Issue
Block a user