Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/SkusTest.php
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$sku = Sku::where('title', 'mailbox')->first(); | $sku = Sku::where('title', 'mailbox')->first(); | ||||
$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(7, $json); | $this->assertCount(8, $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 All 14 Lines | public function testUserSkus(): void | ||||
$response = $this->get("api/v4/users/{$user->id}/skus"); | $response = $this->get("api/v4/users/{$user->id}/skus"); | ||||
$response->assertStatus(401); | $response->assertStatus(401); | ||||
$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(6, $json); | $this->assertCount(7, $json); | ||||
$this->assertSkuElement('mailbox', $json[0], [ | $this->assertSkuElement('mailbox', $json[0], [ | ||||
'prio' => 100, | 'prio' => 100, | ||||
'type' => 'user', | 'type' => 'user', | ||||
'handler' => 'mailbox', | 'handler' => 'mailbox', | ||||
'enabled' => true, | 'enabled' => true, | ||||
'readonly' => true, | 'readonly' => true, | ||||
]); | ]); | ||||
Show All 40 Lines | public function testUserSkus(): void | ||||
$this->assertSkuElement('domain-hosting', $json[5], [ | $this->assertSkuElement('domain-hosting', $json[5], [ | ||||
'prio' => 0, | 'prio' => 0, | ||||
'type' => 'domain', | 'type' => 'domain', | ||||
'handler' => 'domainhosting', | 'handler' => 'domainhosting', | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => false, | 'readonly' => false, | ||||
]); | ]); | ||||
$this->assertSkuElement('group', $json[6], [ | |||||
'prio' => 0, | |||||
'type' => 'group', | |||||
'handler' => 'group', | |||||
'enabled' => false, | |||||
'readonly' => false, | |||||
]); | |||||
// Test filter by type | // Test filter by type | ||||
$response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus?type=domain"); | $response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus?type=domain"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(1, $json); | $this->assertCount(1, $json); | ||||
$this->assertSame('domain', $json[0]['type']); | $this->assertSame('domain', $json[0]['type']); | ||||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |