Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Console/Domain/StatusTest.php
<?php | <?php | ||||
namespace Tests\Feature\Console\Domain; | namespace Tests\Feature\Console\Domain; | ||||
use Illuminate\Support\Facades\Queue; | |||||
use Tests\TestCase; | use Tests\TestCase; | ||||
class StatusTest extends TestCase | class StatusTest extends TestCase | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | |||||
*/ | |||||
public function setUp(): void | |||||
{ | |||||
parent::setUp(); | |||||
$this->deleteTestDomain('domain-delete.com'); | |||||
} | |||||
/** | |||||
* {@inheritDoc} | |||||
*/ | |||||
public function tearDown(): void | |||||
{ | |||||
$this->deleteTestDomain('domain-delete.com'); | |||||
parent::tearDown(); | |||||
} | |||||
/** | |||||
* Test the command | * Test the command | ||||
*/ | */ | ||||
public function testHandle(): void | public function testHandle(): void | ||||
{ | { | ||||
Queue::fake(); | |||||
// Non-existing domain | // Non-existing domain | ||||
$code = \Artisan::call("domain:status unknown.org"); | $code = \Artisan::call("domain:status unknown.org"); | ||||
$output = trim(\Artisan::output()); | $output = trim(\Artisan::output()); | ||||
$this->assertSame(1, $code); | $this->assertSame(1, $code); | ||||
$this->assertSame("Domain not found.", $output); | $this->assertSame("Domain not found.", $output); | ||||
// Existing domain | // Existing domain | ||||
$code = \Artisan::call("domain:status kolab.org"); | $code = \Artisan::call("domain:status kolab.org"); | ||||
$output = trim(\Artisan::output()); | $output = trim(\Artisan::output()); | ||||
$this->assertSame(0, $code); | $this->assertSame(0, $code); | ||||
$this->assertSame("Status (114): active (2), confirmed (16), verified (32), ldapReady (64)", $output); | |||||
$this->assertTrue(strpos($output, "In total: 114") !== false); | // Test deleted domain | ||||
$user = $this->getTestUser('john@kolab.org'); | |||||
$domain = $this->getTestDomain('domain-delete.com', [ | |||||
'status' => \App\Domain::STATUS_NEW, | |||||
'type' => \App\Domain::TYPE_HOSTED, | |||||
]); | |||||
$package_domain = \App\Package::where('title', 'domain-hosting')->first(); | |||||
$domain->assignPackage($package_domain, $user); | |||||
$domain->delete(); | |||||
// TODO: More precise output testing | $code = \Artisan::call("domain:status {$domain->namespace}"); | ||||
$output = trim(\Artisan::output()); | |||||
$this->assertSame(0, $code); | |||||
$this->assertSame("Status (1): deleted (8)", $output); | |||||
} | } | ||||
} | } |