Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Jobs/SharedFolder/UpdateTest.php
Show All 27 Lines | public function tearDown(): void | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test job handle | * Test job handle | ||||
* | * | ||||
* @group ldap | * @group ldap | ||||
* @group imap | |||||
*/ | */ | ||||
public function testHandle(): void | public function testHandle(): void | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
// Test non-existing folder ID | // Test non-existing folder ID | ||||
$job = new \App\Jobs\SharedFolder\UpdateJob(123); | $job = new \App\Jobs\SharedFolder\UpdateJob(123); | ||||
$job->handle(); | $job->handle(); | ||||
$this->assertTrue($job->hasFailed()); | $this->assertTrue($job->hasFailed()); | ||||
$this->assertSame("Shared folder 123 could not be found in the database.", $job->failureMessage); | $this->assertSame("Shared folder 123 could not be found in the database.", $job->failureMessage); | ||||
$folder = $this->getTestSharedFolder('folder-test@' . \config('app.domain')); | $folder = $this->getTestSharedFolder( | ||||
'folder-test@' . \config('app.domain'), | |||||
['status' => SharedFolder::STATUS_NEW] | |||||
); | |||||
// Create the folder in LDAP | // Create the folder in LDAP | ||||
$job = new \App\Jobs\SharedFolder\CreateJob($folder->id); | $job = new \App\Jobs\SharedFolder\CreateJob($folder->id); | ||||
$job->handle(); | $job->handle(); | ||||
$job = new \App\Jobs\SharedFolder\UpdateJob($folder->id); | |||||
$job->handle(); | |||||
$this->assertTrue(is_array(LDAP::getSharedFolder($folder->email))); | |||||
// Test that the job is being deleted if the folder is not ldap ready or is deleted | |||||
$folder->refresh(); | $folder->refresh(); | ||||
$folder->status = SharedFolder::STATUS_NEW | SharedFolder::STATUS_ACTIVE; | |||||
$folder->save(); | |||||
$this->assertTrue($folder->isLdapReady()); | |||||
$this->assertTrue($folder->isImapReady()); | |||||
// Run the update job | |||||
$job = new \App\Jobs\SharedFolder\UpdateJob($folder->id); | $job = new \App\Jobs\SharedFolder\UpdateJob($folder->id); | ||||
$job->handle(); | $job->handle(); | ||||
$this->assertTrue($job->isDeleted()); | // TODO: Assert that it worked on both LDAP and IMAP side | ||||
$folder->status = SharedFolder::STATUS_NEW | SharedFolder::STATUS_ACTIVE | // Test handling deleted folder | ||||
| SharedFolder::STATUS_LDAP_READY | SharedFolder::STATUS_DELETED; | $folder->status |= SharedFolder::STATUS_DELETED; | ||||
$folder->save(); | $folder->save(); | ||||
$job = new \App\Jobs\SharedFolder\UpdateJob($folder->id); | $job = new \App\Jobs\SharedFolder\UpdateJob($folder->id); | ||||
$job->handle(); | $job->handle(); | ||||
$this->assertTrue($job->isDeleted()); | $this->assertTrue($job->isDeleted()); | ||||
} | } | ||||
} | } |