Page MenuHomePhorge

D5250.1774871125.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D5250.1774871125.diff

diff --git a/src/app/Jobs/Domain/DeleteJob.php b/src/app/Jobs/Domain/DeleteJob.php
--- a/src/app/Jobs/Domain/DeleteJob.php
+++ b/src/app/Jobs/Domain/DeleteJob.php
@@ -20,13 +20,13 @@
}
// sanity checks
- if ($domain->trashed()) {
- $this->fail("Domain {$this->domainId} is not deleted.");
+ if (!$domain->trashed()) {
+ $this->fail("Domain {$domain->namespace} is not deleted.");
return;
}
if ($domain->isDeleted()) {
- $this->fail("Domain {$this->domainId} is already marked as deleted.");
+ $this->fail("Domain {$domain->namespace} is already marked as deleted.");
return;
}
diff --git a/src/tests/Feature/Jobs/Domain/DeleteTest.php b/src/tests/Feature/Jobs/Domain/DeleteTest.php
--- a/src/tests/Feature/Jobs/Domain/DeleteTest.php
+++ b/src/tests/Feature/Jobs/Domain/DeleteTest.php
@@ -36,21 +36,33 @@
]
);
- \config(['app.with_ldap' => true]);
+ // Test job failure (domain not trashed)
+ $job = (new DeleteJob($domain->id))->withFakeQueueInteractions();
+ $job->handle();
+ $job->assertFailedWith("Domain {$domain->namespace} is not deleted.");
+
+ // Test job success
+ $domain->deleted_at = \now();
+ $domain->saveQuietly();
$this->assertTrue($domain->isLdapReady());
+ $this->assertTrue($domain->trashed());
$this->assertFalse($domain->isDeleted());
- LDAP::shouldReceive('deleteDomain')->once()->with($domain)->andReturn(true);
+ \config(['app.with_ldap' => true]);
+ LDAP::shouldReceive('deleteDomain')->once()->with($domain);
- $job = new DeleteJob($domain->id);
+ $job = (new DeleteJob($domain->id))->withFakeQueueInteractions();
$job->handle();
+ $job->assertNotFailed();
$domain->refresh();
$this->assertFalse($domain->isLdapReady());
$this->assertTrue($domain->isDeleted());
- // TODO: More cases
- $this->markTestIncomplete();
+ // Test job failure (domain marked as deleted)
+ $job = (new DeleteJob($domain->id))->withFakeQueueInteractions();
+ $job->handle();
+ $job->assertFailedWith("Domain {$domain->namespace} is already marked as deleted.");
}
}

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 30, 11:45 AM (6 d, 10 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18806652
Default Alt Text
D5250.1774871125.diff (2 KB)

Event Timeline