Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/SkusTest.php
Show All 10 Lines | |||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
$betas = Sku::where('handler_class', 'like', '%\\Beta%')->pluck('id')->all(); | $this->clearBetaEntitlements(); | ||||
Entitlement::whereIn('sku_id', $betas)->delete(); | $this->clearMeetEntitlements(); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$betas = Sku::where('handler_class', 'like', '%\\Beta%')->pluck('id')->all(); | $this->clearBetaEntitlements(); | ||||
Entitlement::whereIn('sku_id', $betas)->delete(); | $this->clearMeetEntitlements(); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test fetching SKUs list | * Test fetching SKUs list | ||||
*/ | */ | ||||
Show All 37 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(7, $json); | $this->assertCount(8, $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 32 Lines | public function testUserSkus(): void | ||||
'prio' => 60, | 'prio' => 60, | ||||
'type' => 'user', | 'type' => 'user', | ||||
'handler' => 'auth2f', | 'handler' => 'auth2f', | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => false, | 'readonly' => false, | ||||
'forbidden' => ['activesync'], | 'forbidden' => ['activesync'], | ||||
]); | ]); | ||||
$this->assertSkuElement('domain-hosting', $json[5], [ | $this->assertSkuElement('meet', $json[5], [ | ||||
'prio' => 50, | |||||
'type' => 'user', | |||||
'handler' => 'meet', | |||||
'enabled' => false, | |||||
'readonly' => false, | |||||
'required' => ['groupware'], | |||||
]); | |||||
$this->assertSkuElement('domain-hosting', $json[6], [ | |||||
'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], [ | $this->assertSkuElement('group', $json[7], [ | ||||
'prio' => 0, | 'prio' => 0, | ||||
'type' => 'group', | 'type' => 'group', | ||||
'handler' => 'group', | 'handler' => 'group', | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => false, | 'readonly' => false, | ||||
]); | ]); | ||||
// Test filter by type | // Test filter by type | ||||
Show All 10 Lines | public function testUserSkus(): void | ||||
$user->assignSku($sku); | $user->assignSku($sku); | ||||
$response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus?type=user"); | $response = $this->actingAs($user)->get("api/v4/users/{$user->id}/skus?type=user"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(7, $json); | $this->assertCount(7, $json); | ||||
$this->assertSkuElement('beta', $json[5], [ | $this->assertSkuElement('meet', $json[5], [ | ||||
'prio' => 10, | 'prio' => 50, | ||||
'type' => 'user', | 'type' => 'user', | ||||
'handler' => 'beta', | 'handler' => 'meet', | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => false, | 'readonly' => false, | ||||
'required' => ['groupware'], | |||||
]); | ]); | ||||
$this->assertSkuElement('meet', $json[6], [ | $this->assertSkuElement('beta', $json[6], [ | ||||
'prio' => 0, | 'prio' => 10, | ||||
'type' => 'user', | 'type' => 'user', | ||||
'handler' => 'meet', | 'handler' => 'beta', | ||||
'enabled' => false, | 'enabled' => false, | ||||
'readonly' => 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 | ||||
Show All 22 Lines |