Page MenuHomePhorge

DeleteTest.php
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

DeleteTest.php

<?php
namespace Tests\Feature\Jobs\Domain;
use App\Domain;
use App\Jobs\Domain\DeleteJob;
use App\Support\Facades\LDAP;
use Tests\TestCase;
class DeleteTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-create-test.com');
}
protected function tearDown(): void
{
$this->deleteTestDomain('domain-create-test.com');
parent::tearDown();
}
/**
* Test job handle
*/
public function testHandle(): void
{
$domain = $this->getTestDomain(
'domain-create-test.com',
[
'status' => Domain::STATUS_NEW | Domain::STATUS_LDAP_READY,
'type' => Domain::TYPE_EXTERNAL,
]
);
// 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());
\config(['app.with_ldap' => true]);
LDAP::shouldReceive('deleteDomain')->once()->with($domain);
$job = (new DeleteJob($domain->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
$domain->refresh();
$this->assertFalse($domain->isLdapReady());
$this->assertTrue($domain->isDeleted());
// Test domain marked as deleted
$job = (new DeleteJob($domain->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Apr 24, 10:03 AM (6 d, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18896112
Default Alt Text
DeleteTest.php (1 KB)

Event Timeline