Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Jobs/Resource/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 resource ID | // Test non-existing resource ID | ||||
$job = new \App\Jobs\Resource\UpdateJob(123); | $job = new \App\Jobs\Resource\UpdateJob(123); | ||||
$job->handle(); | $job->handle(); | ||||
$this->assertTrue($job->hasFailed()); | $this->assertTrue($job->hasFailed()); | ||||
$this->assertSame("Resource 123 could not be found in the database.", $job->failureMessage); | $this->assertSame("Resource 123 could not be found in the database.", $job->failureMessage); | ||||
$resource = $this->getTestResource('resource-test@' . \config('app.domain')); | $resource = $this->getTestResource( | ||||
'resource-test@' . \config('app.domain'), | |||||
['status' => Resource::STATUS_NEW] | |||||
); | |||||
// Create the resource in LDAP | // Create the resource in LDAP | ||||
$job = new \App\Jobs\Resource\CreateJob($resource->id); | $job = new \App\Jobs\Resource\CreateJob($resource->id); | ||||
$job->handle(); | $job->handle(); | ||||
// Run the update with some new config | |||||
$resource->setConfig(['invitation_policy' => 'accept']); | $resource->setConfig(['invitation_policy' => 'accept']); | ||||
$job = new \App\Jobs\Resource\UpdateJob($resource->id); | $job = new \App\Jobs\Resource\UpdateJob($resource->id); | ||||
$job->handle(); | $job->handle(); | ||||
$ldap_resource = LDAP::getResource($resource->email); | $ldap_resource = LDAP::getResource($resource->email); | ||||
$this->assertSame('ACT_ACCEPT', $ldap_resource['kolabinvitationpolicy']); | $this->assertSame('ACT_ACCEPT', $ldap_resource['kolabinvitationpolicy']); | ||||
// TODO: Assert IMAP change worked | |||||
// Test that the job is being deleted if the resource is not ldap ready or is deleted | // Test that the job is being deleted if the resource is not ldap ready or is deleted | ||||
$resource->refresh(); | $resource->refresh(); | ||||
$resource->status = Resource::STATUS_NEW | Resource::STATUS_ACTIVE; | $resource->status |= Resource::STATUS_DELETED; | ||||
$resource->save(); | |||||
$job = new \App\Jobs\Resource\UpdateJob($resource->id); | |||||
$job->handle(); | |||||
$this->assertTrue($job->isDeleted()); | |||||
$resource->status = Resource::STATUS_NEW | Resource::STATUS_ACTIVE | |||||
| Resource::STATUS_LDAP_READY | Resource::STATUS_DELETED; | |||||
$resource->save(); | $resource->save(); | ||||
$job = new \App\Jobs\Resource\UpdateJob($resource->id); | $job = new \App\Jobs\Resource\UpdateJob($resource->id); | ||||
$job->handle(); | $job->handle(); | ||||
$this->assertTrue($job->isDeleted()); | $this->assertTrue($job->isDeleted()); | ||||
} | } | ||||
} | } |