Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/SkusTest.php
Show First 20 Lines • Show All 99 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$nsku->tenant_id = $tenant->id; | $nsku->tenant_id = $tenant->id; | ||||
$nsku->save(); | $nsku->save(); | ||||
$response = $this->actingAs($user)->get("api/v4/skus"); | $response = $this->actingAs($user)->get("api/v4/skus"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(11, $json); | $this->assertCount(13, $json); | ||||
$this->assertSame(100, $json[0]['prio']); | $this->assertSame(100, $json[0]['prio']); | ||||
$this->assertSame($sku->id, $json[0]['id']); | $this->assertSame($sku->id, $json[0]['id']); | ||||
$this->assertSame($sku->title, $json[0]['title']); | $this->assertSame($sku->title, $json[0]['title']); | ||||
$this->assertSame($sku->name, $json[0]['name']); | $this->assertSame($sku->name, $json[0]['name']); | ||||
$this->assertSame($sku->description, $json[0]['description']); | $this->assertSame($sku->description, $json[0]['description']); | ||||
$this->assertSame($sku->cost, $json[0]['cost']); | $this->assertSame($sku->cost, $json[0]['cost']); | ||||
$this->assertSame($sku->units_free, $json[0]['units_free']); | $this->assertSame($sku->units_free, $json[0]['units_free']); | ||||
▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | public function testUserSkus(): void | ||||
// Test inclusion of beta SKUs | // Test inclusion of beta SKUs | ||||
$sku = Sku::withEnvTenantContext()->where('title', 'beta')->first(); | $sku = Sku::withEnvTenantContext()->where('title', 'beta')->first(); | ||||
$user->assignSku($sku); | $user->assignSku($sku); | ||||
$response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus"); | $response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(9, $json); | $this->assertCount(10, $json); | ||||
$this->assertSkuElement('beta', $json[6], [ | $this->assertSkuElement('beta', $json[6], [ | ||||
'prio' => 10, | 'prio' => 10, | ||||
'type' => 'user', | 'type' => 'user', | ||||
'handler' => 'beta', | 'handler' => 'beta', | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => false, | 'readonly' => false, | ||||
]); | ]); | ||||
$this->assertSkuElement('beta-resources', $json[7], [ | $this->assertSkuElement('beta-resources', $json[7], [ | ||||
'prio' => 10, | 'prio' => 10, | ||||
'type' => 'user', | 'type' => 'user', | ||||
'handler' => 'resources', // TODO: shouldn't it be beta-resources or beta/resources? | 'handler' => 'resources', // TODO: shouldn't it be beta-resources or beta/resources? | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => false, | 'readonly' => false, | ||||
'required' => ['beta'], | 'required' => ['beta'], | ||||
]); | ]); | ||||
$this->assertSkuElement('distlist', $json[8], [ | $this->assertSkuElement('beta-shared-folders', $json[8], [ | ||||
'prio' => 10, | |||||
'type' => 'user', | |||||
'handler' => 'sharedfolders', | |||||
'enabled' => false, | |||||
'readonly' => false, | |||||
'required' => ['beta'], | |||||
]); | |||||
$this->assertSkuElement('distlist', $json[9], [ | |||||
'prio' => 10, | 'prio' => 10, | ||||
'type' => 'user', | 'type' => 'user', | ||||
'handler' => 'distlist', | 'handler' => 'distlist', | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => false, | 'readonly' => false, | ||||
'required' => ['beta'], | 'required' => ['beta'], | ||||
]); | ]); | ||||
} | } | ||||
Show All 28 Lines |