Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/UsersTest.php
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$this->assertSame(2, $json['count']); | $this->assertSame(2, $json['count']); | ||||
$this->assertCount(2, $json['list']); | $this->assertCount(2, $json['list']); | ||||
$emails = array_column($json['list'], 'email'); | $emails = array_column($json['list'], 'email'); | ||||
$this->assertContains($user->email, $emails); | $this->assertContains($user->email, $emails); | ||||
$this->assertContains($jack->email, $emails); | $this->assertContains($jack->email, $emails); | ||||
// Search by owner | |||||
$response = $this->actingAs($admin)->get("api/v4/users?owner={$user->id}"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertSame(4, $json['count']); | |||||
$this->assertCount(4, $json['list']); | |||||
// Search by owner (Ned is a controller on John's wallets, | |||||
// here we expect only users assigned to Ned's wallet(s)) | |||||
$ned = $this->getTestUser('ned@kolab.org'); | |||||
$response = $this->actingAs($admin)->get("api/v4/users?owner={$ned->id}"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertSame(0, $json['count']); | |||||
$this->assertCount(0, $json['list']); | |||||
} | } | ||||
} | } |