Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/UsersTest.php
Show First 20 Lines • Show All 489 Lines • ▼ Show 20 Lines | public function testStatus(): void | ||||
$this->assertTrue(empty($json['status'])); | $this->assertTrue(empty($json['status'])); | ||||
$this->assertTrue(empty($json['message'])); | $this->assertTrue(empty($json['message'])); | ||||
// 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 |= Domain::STATUS_CONFIRMED; | $domain->status |= Domain::STATUS_CONFIRMED; | ||||
$domain->save(); | $domain->save(); | ||||
// Now "reboot" the process and verify the user in imap synchronously | // Now "reboot" the process | ||||
$response = $this->actingAs($john)->get("/api/v4/users/{$john->id}/status?refresh=1"); | Queue::fake(); | ||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertTrue($json['isImapReady']); | |||||
$this->assertTrue($json['isReady']); | |||||
$this->assertCount(7, $json['process']); | |||||
$this->assertSame('user-imap-ready', $json['process'][2]['label']); | |||||
$this->assertSame(true, $json['process'][2]['state']); | |||||
$this->assertSame('success', $json['status']); | |||||
$this->assertSame('Setup process finished successfully.', $json['message']); | |||||
Queue::size(1); | |||||
// Test case for when the verify job is dispatched to the worker | |||||
$john->refresh(); | |||||
$john->status ^= User::STATUS_IMAP_READY; | |||||
$john->save(); | |||||
\config(['imap.admin_password' => null]); | |||||
$response = $this->actingAs($john)->get("/api/v4/users/{$john->id}/status?refresh=1"); | $response = $this->actingAs($john)->get("/api/v4/users/{$john->id}/status?refresh=1"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertFalse($json['isImapReady']); | $this->assertFalse($json['isImapReady']); | ||||
$this->assertFalse($json['isReady']); | $this->assertFalse($json['isReady']); | ||||
$this->assertCount(7, $json['process']); | |||||
$this->assertSame('user-imap-ready', $json['process'][2]['label']); | |||||
$this->assertSame(false, $json['process'][2]['state']); | |||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame('waiting', $json['processState']); | |||||
$this->assertSame('Setup process has been pushed. Please wait.', $json['message']); | $this->assertSame('Setup process has been pushed. Please wait.', $json['message']); | ||||
Queue::assertPushed(\App\Jobs\User\VerifyJob::class, 1); | Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1); | ||||
} | } | ||||
/** | /** | ||||
* Test UsersController::statusInfo() | * Test UsersController::statusInfo() | ||||
*/ | */ | ||||
public function testStatusInfo(): void | public function testStatusInfo(): void | ||||
{ | { | ||||
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | $user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | ||||
▲ Show 20 Lines • Show All 1,098 Lines • Show Last 20 Lines |