Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/GroupsTest.php
- This file was copied to src/tests/Feature/Controller/Reseller/GroupsTest.php.
Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame(0, $json['count']); | $this->assertSame(0, $json['count']); | ||||
$this->assertCount(0, $json['list']); | $this->assertCount(0, $json['list']); | ||||
} | } | ||||
/** | /** | ||||
* Test fetching group info | |||||
*/ | |||||
public function testShow(): void | |||||
{ | |||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | |||||
$user = $this->getTestUser('test1@domainscontroller.com'); | |||||
$group = $this->getTestGroup('group-test@kolab.org'); | |||||
$group->assignToWallet($user->wallets->first()); | |||||
// Only admins can access it | |||||
$response = $this->actingAs($user)->get("api/v4/groups/{$group->id}"); | |||||
$response->assertStatus(403); | |||||
$response = $this->actingAs($admin)->get("api/v4/groups/{$group->id}"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertEquals($group->id, $json['id']); | |||||
$this->assertEquals($group->email, $json['email']); | |||||
$this->assertEquals($group->status, $json['status']); | |||||
} | |||||
/** | |||||
* Test fetching domain status (GET /api/v4/domains/<domain-id>/status) | |||||
*/ | |||||
public function testStatus(): void | |||||
{ | |||||
Queue::fake(); // disable jobs | |||||
$user = $this->getTestUser('john@kolab.org'); | |||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | |||||
$group = $this->getTestGroup('group-test@kolab.org'); | |||||
$group->assignToWallet($user->wallets->first()); | |||||
// This end-point does not exist for admins | |||||
$response = $this->actingAs($admin)->get("/api/v4/groups/{$group->id}/status"); | |||||
$response->assertStatus(404); | |||||
} | |||||
/** | |||||
* Test group creating (POST /api/v4/groups) | * Test group creating (POST /api/v4/groups) | ||||
*/ | */ | ||||
public function testStore(): void | public function testStore(): void | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
// Test unauthorized access to admin API | // Test unauthorized access to admin API | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |