Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/UsersTest.php
Show First 20 Lines • Show All 649 Lines • ▼ Show 20 Lines | public function testStore(): void | ||||
$this->assertSame('John2', $user->getSetting('first_name')); | $this->assertSame('John2', $user->getSetting('first_name')); | ||||
$this->assertSame('Doe2', $user->getSetting('last_name')); | $this->assertSame('Doe2', $user->getSetting('last_name')); | ||||
$this->assertSame('TestOrg', $user->getSetting('organization')); | $this->assertSame('TestOrg', $user->getSetting('organization')); | ||||
$aliases = $user->aliases()->orderBy('alias')->get(); | $aliases = $user->aliases()->orderBy('alias')->get(); | ||||
$this->assertCount(2, $aliases); | $this->assertCount(2, $aliases); | ||||
$this->assertSame('deleted@kolab.org', $aliases[0]->alias); | $this->assertSame('deleted@kolab.org', $aliases[0]->alias); | ||||
$this->assertSame('useralias1@kolab.org', $aliases[1]->alias); | $this->assertSame('useralias1@kolab.org', $aliases[1]->alias); | ||||
// Assert the new user entitlements | // Assert the new user entitlements | ||||
$this->assertUserEntitlements($user, ['groupware', 'mailbox', | $this->assertEntitlements($user, ['groupware', 'mailbox', | ||||
'storage', 'storage', 'storage', 'storage', 'storage']); | 'storage', 'storage', 'storage', 'storage', 'storage']); | ||||
// Assert the wallet to which the new user should be assigned to | // Assert the wallet to which the new user should be assigned to | ||||
$wallet = $user->wallet(); | $wallet = $user->wallet(); | ||||
$this->assertSame($john->wallets()->first()->id, $wallet->id); | $this->assertSame($john->wallets()->first()->id, $wallet->id); | ||||
// Attempt to create a user previously deleted | // Attempt to create a user previously deleted | ||||
$user->delete(); | $user->delete(); | ||||
Show All 9 Lines | public function testStore(): void | ||||
$this->assertCount(2, $json); | $this->assertCount(2, $json); | ||||
$user = User::where('email', 'john2.doe2@kolab.org')->first(); | $user = User::where('email', 'john2.doe2@kolab.org')->first(); | ||||
$this->assertInstanceOf(User::class, $user); | $this->assertInstanceOf(User::class, $user); | ||||
$this->assertSame('John2', $user->getSetting('first_name')); | $this->assertSame('John2', $user->getSetting('first_name')); | ||||
$this->assertSame('Doe2', $user->getSetting('last_name')); | $this->assertSame('Doe2', $user->getSetting('last_name')); | ||||
$this->assertSame('TestOrg', $user->getSetting('organization')); | $this->assertSame('TestOrg', $user->getSetting('organization')); | ||||
$this->assertCount(0, $user->aliases()->get()); | $this->assertCount(0, $user->aliases()->get()); | ||||
$this->assertUserEntitlements($user, ['groupware', 'mailbox', | $this->assertEntitlements($user, ['groupware', 'mailbox', | ||||
'storage', 'storage', 'storage', 'storage', 'storage']); | 'storage', 'storage', 'storage', 'storage', 'storage']); | ||||
// Test acting as account controller (not owner) | // Test acting as account controller (not owner) | ||||
$this->markTestIncomplete(); | $this->markTestIncomplete(); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | public function testUpdate(): void | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$storage_cost = $user->entitlements() | $storage_cost = $user->entitlements() | ||||
->where('sku_id', $sku_storage->id) | ->where('sku_id', $sku_storage->id) | ||||
->orderBy('cost') | ->orderBy('cost') | ||||
->pluck('cost')->all(); | ->pluck('cost')->all(); | ||||
$this->assertUserEntitlements( | $this->assertEntitlements( | ||||
$user, | $user, | ||||
['groupware', 'mailbox', 'storage', 'storage', 'storage', 'storage', 'storage', 'storage'] | ['groupware', 'mailbox', 'storage', 'storage', 'storage', 'storage', 'storage', 'storage'] | ||||
); | ); | ||||
$this->assertSame([0, 0, 0, 0, 0, 25], $storage_cost); | $this->assertSame([0, 0, 0, 0, 0, 25], $storage_cost); | ||||
$this->assertTrue(empty($json['statusInfo'])); | $this->assertTrue(empty($json['statusInfo'])); | ||||
} | } | ||||
Show All 21 Lines | public function testUpdateEntitlements(): void | ||||
$storage->id => 7, | $storage->id => 7, | ||||
$activesync->id => 1 | $activesync->id => 1 | ||||
] | ] | ||||
]; | ]; | ||||
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | $response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertUserEntitlements( | $this->assertEntitlements( | ||||
$jane, | $jane, | ||||
[ | [ | ||||
'activesync', | 'activesync', | ||||
'groupware', | 'groupware', | ||||
'mailbox', | 'mailbox', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
Show All 12 Lines | public function testUpdateEntitlements(): void | ||||
$storage->id => 9, | $storage->id => 9, | ||||
$activesync->id => 0 | $activesync->id => 0 | ||||
] | ] | ||||
]; | ]; | ||||
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | $response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertUserEntitlements( | $this->assertEntitlements( | ||||
$jane, | $jane, | ||||
[ | [ | ||||
'groupware', | 'groupware', | ||||
'mailbox', | 'mailbox', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
Show All 13 Lines | public function testUpdateEntitlements(): void | ||||
$storage->id => 9, | $storage->id => 9, | ||||
$activesync->id => 0 | $activesync->id => 0 | ||||
] | ] | ||||
]; | ]; | ||||
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | $response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | ||||
$response->assertStatus(500); | $response->assertStatus(500); | ||||
$this->assertUserEntitlements( | $this->assertEntitlements( | ||||
$jane, | $jane, | ||||
[ | [ | ||||
'groupware', | 'groupware', | ||||
'mailbox', | 'mailbox', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
Show All 13 Lines | public function testUpdateEntitlements(): void | ||||
$storage->id => 9, | $storage->id => 9, | ||||
$activesync->id => 0 | $activesync->id => 0 | ||||
] | ] | ||||
]; | ]; | ||||
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | $response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | ||||
$response->assertStatus(500); | $response->assertStatus(500); | ||||
$this->assertUserEntitlements( | $this->assertEntitlements( | ||||
$jane, | $jane, | ||||
[ | [ | ||||
'groupware', | 'groupware', | ||||
'mailbox', | 'mailbox', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
Show All 13 Lines | public function testUpdateEntitlements(): void | ||||
$storage->id => 1, | $storage->id => 1, | ||||
$activesync->id => 0 | $activesync->id => 0 | ||||
] | ] | ||||
]; | ]; | ||||
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | $response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertUserEntitlements( | $this->assertEntitlements( | ||||
$jane, | $jane, | ||||
[ | [ | ||||
'groupware', | 'groupware', | ||||
'mailbox', | 'mailbox', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
'storage', | 'storage', | ||||
▲ Show 20 Lines • Show All 313 Lines • Show Last 20 Lines |