Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/ResourcesTest.php
Show First 20 Lines • Show All 333 Lines • ▼ Show 20 Lines | public function testStatus(): void | ||||
// Make sure the domain is confirmed (other test might unset that status) | // Make sure the domain is confirmed (other test might unset that status) | ||||
$domain = $this->getTestDomain('kolab.org'); | $domain = $this->getTestDomain('kolab.org'); | ||||
$domain->status |= \App\Domain::STATUS_CONFIRMED; | $domain->status |= \App\Domain::STATUS_CONFIRMED; | ||||
$domain->save(); | $domain->save(); | ||||
$resource->status |= Resource::STATUS_IMAP_READY; | $resource->status |= Resource::STATUS_IMAP_READY; | ||||
$resource->save(); | $resource->save(); | ||||
// Now "reboot" the process and get the resource status | // Now "reboot" the process | ||||
Queue::fake(); | |||||
$response = $this->actingAs($john)->get("/api/v4/resources/{$resource->id}/status?refresh=1"); | $response = $this->actingAs($john)->get("/api/v4/resources/{$resource->id}/status?refresh=1"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertTrue($json['isLdapReady']); | $this->assertFalse($json['isLdapReady']); | ||||
$this->assertTrue($json['isImapReady']); | $this->assertTrue($json['isImapReady']); | ||||
$this->assertTrue($json['isReady']); | $this->assertFalse($json['isReady']); | ||||
$this->assertCount(7, $json['process']); | $this->assertCount(7, $json['process']); | ||||
$this->assertSame('resource-ldap-ready', $json['process'][1]['label']); | $this->assertSame('resource-ldap-ready', $json['process'][1]['label']); | ||||
$this->assertSame(true, $json['process'][1]['state']); | $this->assertSame(false, $json['process'][1]['state']); | ||||
$this->assertSame('resource-imap-ready', $json['process'][2]['label']); | $this->assertSame('resource-imap-ready', $json['process'][2]['label']); | ||||
$this->assertSame(true, $json['process'][2]['state']); | $this->assertSame(true, $json['process'][2]['state']); | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame('Setup process finished successfully.', $json['message']); | $this->assertSame('Setup process has been pushed. Please wait.', $json['message']); | ||||
$this->assertSame('done', $json['processState']); | $this->assertSame('waiting', $json['processState']); | ||||
Queue::assertPushed(\App\Jobs\Resource\CreateJob::class, 1); | |||||
// Test a case when a domain is not ready | // Test a case when a domain is not ready | ||||
Queue::fake(); | |||||
$domain->status ^= \App\Domain::STATUS_CONFIRMED; | $domain->status ^= \App\Domain::STATUS_CONFIRMED; | ||||
$domain->save(); | $domain->save(); | ||||
$response = $this->actingAs($john)->get("/api/v4/resources/{$resource->id}/status?refresh=1"); | $response = $this->actingAs($john)->get("/api/v4/resources/{$resource->id}/status?refresh=1"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertTrue($json['isLdapReady']); | $this->assertFalse($json['isLdapReady']); | ||||
$this->assertTrue($json['isReady']); | $this->assertFalse($json['isReady']); | ||||
$this->assertCount(7, $json['process']); | $this->assertCount(7, $json['process']); | ||||
$this->assertSame('resource-ldap-ready', $json['process'][1]['label']); | $this->assertSame('resource-ldap-ready', $json['process'][1]['label']); | ||||
$this->assertSame(true, $json['process'][1]['state']); | $this->assertSame(false, $json['process'][1]['state']); | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame('Setup process finished successfully.', $json['message']); | $this->assertSame('Setup process has been pushed. Please wait.', $json['message']); | ||||
$this->assertSame('waiting', $json['processState']); | |||||
Queue::assertPushed(\App\Jobs\Resource\CreateJob::class, 1); | |||||
} | } | ||||
/** | /** | ||||
* Test ResourcesController::statusInfo() | * Test ResourcesController::statusInfo() | ||||
*/ | */ | ||||
public function testStatusInfo(): void | public function testStatusInfo(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
▲ Show 20 Lines • Show All 148 Lines • Show Last 20 Lines |