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