Page MenuHomePhorge

DeleteTest.php
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

DeleteTest.php

<?php
namespace Tests\Feature\Console\Domain;
use App\Domain;
use App\Package;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class DeleteTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@domain-delete.com');
$this->deleteTestDomain('domain-delete.com');
}
protected function tearDown(): void
{
$this->deleteTestUser('user@domain-delete.com');
$this->deleteTestDomain('domain-delete.com');
parent::tearDown();
}
/**
* Test the command
*/
public function testHandle(): void
{
Queue::fake();
// Non-existing domain
$code = \Artisan::call("domain:delete unknown.org");
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
$this->assertSame("Domain not found.", $output);
// Public domain
$code = \Artisan::call("domain:delete " . \config('app.domain'));
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
$this->assertSame("This domain is a public registration domain.", $output);
// Create a user account for delete
$user = $this->getTestUser('user@domain-delete.com');
$domain = $this->getTestDomain('domain-delete.com', [
'status' => Domain::STATUS_NEW,
'type' => Domain::TYPE_HOSTED,
]);
$package_kolab = Package::where('title', 'kolab')->first();
$package_domain = Package::where('title', 'domain-hosting')->first();
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
// Non-deleted domain
$code = \Artisan::call("domain:delete domain-delete.com");
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
$this->assertSame("", $output);
$this->assertTrue($domain->fresh()->trashed());
$this->assertFalse($user->fresh()->trashed());
// Deleted domain
$code = \Artisan::call("domain:delete domain-delete.com");
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
$this->assertSame("Domain not found.", $output);
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Apr 24, 1:48 PM (3 d, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18828479
Default Alt Text
DeleteTest.php (2 KB)

Event Timeline