Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/SharedFoldersTest.php
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
$response->assertStatus(401); | $response->assertStatus(401); | ||||
// Test a user with no shared folders | // Test a user with no shared folders | ||||
$response = $this->actingAs($jack)->get("/api/v4/shared-folders"); | $response = $this->actingAs($jack)->get("/api/v4/shared-folders"); | ||||
$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 shared folders have been found.", $json['message']); | |||||
$this->assertSame([], $json['list']); | |||||
// Test a user with two shared folders | // Test a user with two shared folders | ||||
$response = $this->actingAs($john)->get("/api/v4/shared-folders"); | $response = $this->actingAs($john)->get("/api/v4/shared-folders"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$folder = SharedFolder::where('name', 'Calendar')->first(); | $folder = SharedFolder::where('name', 'Calendar')->first(); | ||||
$this->assertCount(2, $json); | $this->assertCount(4, $json); | ||||
$this->assertSame($folder->id, $json[0]['id']); | $this->assertSame(2, $json['count']); | ||||
$this->assertSame($folder->email, $json[0]['email']); | $this->assertSame(false, $json['hasMore']); | ||||
$this->assertSame($folder->name, $json[0]['name']); | $this->assertSame("2 shared folders have been found.", $json['message']); | ||||
$this->assertSame($folder->type, $json[0]['type']); | $this->assertCount(2, $json['list']); | ||||
$this->assertArrayHasKey('isDeleted', $json[0]); | $this->assertSame($folder->id, $json['list'][0]['id']); | ||||
$this->assertArrayHasKey('isActive', $json[0]); | $this->assertSame($folder->email, $json['list'][0]['email']); | ||||
$this->assertArrayHasKey('isLdapReady', $json[0]); | $this->assertSame($folder->name, $json['list'][0]['name']); | ||||
$this->assertArrayHasKey('isImapReady', $json[0]); | $this->assertSame($folder->type, $json['list'][0]['type']); | ||||
$this->assertArrayHasKey('isDeleted', $json['list'][0]); | |||||
$this->assertArrayHasKey('isActive', $json['list'][0]); | |||||
$this->assertArrayHasKey('isLdapReady', $json['list'][0]); | |||||
$this->assertArrayHasKey('isImapReady', $json['list'][0]); | |||||
// Test that another wallet controller has access to shared folders | // Test that another wallet controller has access to shared folders | ||||
$response = $this->actingAs($ned)->get("/api/v4/shared-folders"); | $response = $this->actingAs($ned)->get("/api/v4/shared-folders"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(2, $json); | $this->assertCount(4, $json); | ||||
$this->assertSame($folder->email, $json[0]['email']); | $this->assertSame(2, $json['count']); | ||||
$this->assertSame(false, $json['hasMore']); | |||||
$this->assertSame("2 shared folders have been found.", $json['message']); | |||||
$this->assertCount(2, $json['list']); | |||||
$this->assertSame($folder->email, $json['list'][0]['email']); | |||||
} | } | ||||
/** | /** | ||||
* Test shared folder config update (POST /api/v4/shared-folders/<folder>/config) | * Test shared folder config update (POST /api/v4/shared-folders/<folder>/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 423 Lines • Show Last 20 Lines |