Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/GroupsTest.php
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$response->assertStatus(401); | $response->assertStatus(401); | ||||
// Test a user with no groups | // Test a user with no groups | ||||
$response = $this->actingAs($jack)->get("/api/v4/groups"); | $response = $this->actingAs($jack)->get("/api/v4/groups"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(0, $json); | $this->assertCount(4, $json); | ||||
$this->assertSame(0, $json['count']); | |||||
$this->assertSame(false, $json['hasMore']); | |||||
$this->assertSame("0 distribution lists have been found.", $json['message']); | |||||
$this->assertSame([], $json['list']); | |||||
// Test a user with a single group | // Test a user with a single group | ||||
$response = $this->actingAs($john)->get("/api/v4/groups"); | $response = $this->actingAs($john)->get("/api/v4/groups"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(1, $json); | $this->assertCount(4, $json); | ||||
$this->assertSame($group->id, $json[0]['id']); | $this->assertSame(1, $json['count']); | ||||
$this->assertSame($group->email, $json[0]['email']); | $this->assertSame(false, $json['hasMore']); | ||||
$this->assertSame($group->name, $json[0]['name']); | $this->assertSame("1 distribution lists have been found.", $json['message']); | ||||
$this->assertArrayHasKey('isDeleted', $json[0]); | $this->assertCount(1, $json['list']); | ||||
$this->assertArrayHasKey('isSuspended', $json[0]); | $this->assertSame($group->id, $json['list'][0]['id']); | ||||
$this->assertArrayHasKey('isActive', $json[0]); | $this->assertSame($group->email, $json['list'][0]['email']); | ||||
$this->assertArrayHasKey('isLdapReady', $json[0]); | $this->assertSame($group->name, $json['list'][0]['name']); | ||||
$this->assertArrayHasKey('isDeleted', $json['list'][0]); | |||||
$this->assertArrayHasKey('isSuspended', $json['list'][0]); | |||||
$this->assertArrayHasKey('isActive', $json['list'][0]); | |||||
$this->assertArrayHasKey('isLdapReady', $json['list'][0]); | |||||
// Test that another wallet controller has access to groups | // Test that another wallet controller has access to groups | ||||
$response = $this->actingAs($ned)->get("/api/v4/groups"); | $response = $this->actingAs($ned)->get("/api/v4/groups"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(1, $json); | $this->assertCount(4, $json); | ||||
$this->assertSame($group->email, $json[0]['email']); | $this->assertSame(1, $json['count']); | ||||
$this->assertSame(false, $json['hasMore']); | |||||
$this->assertSame("1 distribution lists have been found.", $json['message']); | |||||
$this->assertCount(1, $json['list']); | |||||
$this->assertSame($group->email, $json['list'][0]['email']); | |||||
} | } | ||||
/** | /** | ||||
* Test group config update (POST /api/v4/groups/<group>/config) | * Test group config update (POST /api/v4/groups/<group>/config) | ||||
*/ | */ | ||||
public function testSetConfig(): void | public function testSetConfig(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
▲ Show 20 Lines • Show All 473 Lines • Show Last 20 Lines |