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(14, $json); | $this->assertCount(10, $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(11, $json); | $this->assertCount(6, $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-distlists', $json[7], [ | |||||
'prio' => 10, | |||||
'type' => 'user', | |||||
'handler' => 'Beta\Distlists', | |||||
'enabled' => false, | |||||
'readonly' => false, | |||||
'required' => ['Beta'], | |||||
]); | |||||
$this->assertSkuElement('beta-resources', $json[8], [ | |||||
'prio' => 10, | |||||
'type' => 'user', | |||||
'handler' => 'Beta\Resources', | |||||
'enabled' => false, | |||||
'readonly' => false, | |||||
'required' => ['Beta'], | |||||
]); | |||||
$this->assertSkuElement('beta-shared-folders', $json[9], [ | |||||
'prio' => 10, | |||||
'type' => 'user', | |||||
'handler' => 'Beta\SharedFolders', | |||||
'enabled' => false, | |||||
'readonly' => false, | |||||
'required' => ['Beta'], | |||||
]); | |||||
$this->assertSkuElement('files', $json[10], [ | |||||
'prio' => 10, | |||||
'type' => 'user', | |||||
'handler' => 'Files', | |||||
'enabled' => false, | |||||
'readonly' => false, | |||||
'required' => ['Beta'], | |||||
]); | |||||
} | } | ||||
/** | /** | ||||
* Assert content of the SKU element in an API response | * Assert content of the SKU element in an API response | ||||
* | * | ||||
* @param string $sku_title The SKU title | * @param string $sku_title The SKU title | ||||
* @param array $result The result to assert | * @param array $result The result to assert | ||||
* @param array $other Other items the SKU itself does not include | * @param array $other Other items the SKU itself does not include | ||||
Show All 21 Lines |