Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/SkusTest.php
Show All 29 Lines | public function tearDown(): void | ||||
$this->clearBetaEntitlements(); | $this->clearBetaEntitlements(); | ||||
$this->clearMeetEntitlements(); | $this->clearMeetEntitlements(); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test fetching SKUs list for a domain (GET /domains/<id>/skus) | |||||
*/ | |||||
public function testDomainSkus(): void | |||||
{ | |||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | |||||
$user = $this->getTestUser('john@kolab.org'); | |||||
$domain = $this->getTestDOmain('kolab.org'); | |||||
// Unauth access not allowed | |||||
$response = $this->get("api/v4/domains/{$domain->id}/skus"); | |||||
$response->assertStatus(401); | |||||
// Non-admin access not allowed | |||||
$response = $this->actingAs($user)->get("api/v4/domains/{$domain->id}/skus"); | |||||
$response->assertStatus(403); | |||||
$response = $this->actingAs($admin)->get("api/v4/domains/{$domain->id}/skus"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertCount(1, $json); | |||||
// Note: Details are tested where we test API\V4\SkusController | |||||
} | |||||
/** | |||||
* Test fetching SKUs list | * Test fetching SKUs list | ||||
*/ | */ | ||||
public function testIndex(): void | public function testIndex(): void | ||||
{ | { | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$sku = Sku::withEnvTenantContext()->where('title', 'mailbox')->first(); | $sku = Sku::withEnvTenantContext()->where('title', 'mailbox')->first(); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | public function testUserSkus(): void | ||||
$response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus"); | $response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
$response = $this->actingAs($admin)->get("api/v4/users/{$user->id}/skus"); | $response = $this->actingAs($admin)->get("api/v4/users/{$user->id}/skus"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(8, $json); | $this->assertCount(6, $json); | ||||
// Note: Details are tested where we test API\V4\SkusController | // Note: Details are tested where we test API\V4\SkusController | ||||
} | } | ||||
} | } |