diff --git a/src/app/Console/Commands/Domain/SuspendCommand.php b/src/app/Console/Commands/Domain/SuspendCommand.php index 28834cde..18f992aa 100644 --- a/src/app/Console/Commands/Domain/SuspendCommand.php +++ b/src/app/Console/Commands/Domain/SuspendCommand.php @@ -1,41 +1,39 @@ getDomain($this->argument('domain')); if (!$domain) { $this->error("Domain not found."); return 1; } - $this->info("Found domain {$domain->id}"); - $domain->suspend(); } } diff --git a/src/app/Console/Commands/Domain/UnsuspendCommand.php b/src/app/Console/Commands/Domain/UnsuspendCommand.php index 9841632e..ae7ace08 100644 --- a/src/app/Console/Commands/Domain/UnsuspendCommand.php +++ b/src/app/Console/Commands/Domain/UnsuspendCommand.php @@ -1,41 +1,39 @@ getDomain($this->argument('domain')); if (!$domain) { $this->error("Domain not found."); return 1; } - $this->info("Found domain {$domain->id}"); - $domain->unsuspend(); } } diff --git a/src/app/Console/Development/DomainStatus.php b/src/app/Console/Development/DomainStatus.php index 47c26b65..439409ed 100644 --- a/src/app/Console/Development/DomainStatus.php +++ b/src/app/Console/Development/DomainStatus.php @@ -1,77 +1,75 @@ argument('domain'))->firstOrFail(); - $this->info("Found domain: {$domain->id}"); - $statuses = [ 'active' => Domain::STATUS_ACTIVE, 'suspended' => Domain::STATUS_SUSPENDED, 'deleted' => Domain::STATUS_DELETED, 'ldapReady' => Domain::STATUS_LDAP_READY, 'verified' => Domain::STATUS_VERIFIED, 'confirmed' => Domain::STATUS_CONFIRMED, ]; // I'd prefer "-state" and "+state" syntax, but it's not possible $delete = false; if ($update = $this->option('del')) { $delete = true; } elseif ($update = $this->option('add')) { // do nothing } if (!empty($update)) { $map = \array_change_key_case($statuses); $update = \strtolower($update); if (isset($map[$update])) { if ($delete && $domain->status & $map[$update]) { $domain->status ^= $map[$update]; $domain->save(); } elseif (!$delete && !($domain->status & $map[$update])) { $domain->status |= $map[$update]; $domain->save(); } } } $domain_state = []; foreach (\array_keys($statuses) as $state) { $func = 'is' . \ucfirst($state); if ($domain->$func()) { $domain_state[] = $state; } } $this->info("Status: " . \implode(',', $domain_state)); } } diff --git a/src/tests/Feature/Console/Domain/SuspendTest.php b/src/tests/Feature/Console/Domain/SuspendTest.php index a7f2090f..47bbeccd 100644 --- a/src/tests/Feature/Console/Domain/SuspendTest.php +++ b/src/tests/Feature/Console/Domain/SuspendTest.php @@ -1,55 +1,55 @@ deleteTestDomain('domain-delete.com'); } /** * {@inheritDoc} */ public function tearDown(): void { $this->deleteTestDomain('domain-delete.com'); parent::tearDown(); } /** * Test the command */ public function testHandle(): void { Queue::fake(); // Non-existing domain $code = \Artisan::call("domain:suspend unknown.org"); $output = trim(\Artisan::output()); $this->assertSame(1, $code); $this->assertSame("Domain not found.", $output); $domain = $this->getTestDomain('domain-delete.com', [ 'status' => \App\Domain::STATUS_NEW, 'type' => \App\Domain::TYPE_HOSTED, ]); $code = \Artisan::call("domain:suspend {$domain->namespace}"); $output = trim(\Artisan::output()); $this->assertSame(0, $code); - $this->assertSame("Found domain {$domain->id}", $output); + $this->assertSame("", $output); $this->assertTrue($domain->fresh()->isSuspended()); } } diff --git a/src/tests/Feature/Console/Domain/UnsuspendTest.php b/src/tests/Feature/Console/Domain/UnsuspendTest.php index 3d5ec8fc..ea183cff 100644 --- a/src/tests/Feature/Console/Domain/UnsuspendTest.php +++ b/src/tests/Feature/Console/Domain/UnsuspendTest.php @@ -1,57 +1,57 @@ deleteTestDomain('domain-delete.com'); } /** * {@inheritDoc} */ public function tearDown(): void { $this->deleteTestDomain('domain-delete.com'); parent::tearDown(); } /** * Test the command */ public function testHandle(): void { Queue::fake(); // Non-existing domain $code = \Artisan::call("domain:unsuspend unknown.org"); $output = trim(\Artisan::output()); $this->assertSame(1, $code); $this->assertSame("Domain not found.", $output); $domain = $this->getTestDomain('domain-delete.com', [ 'status' => \App\Domain::STATUS_NEW | \App\Domain::STATUS_SUSPENDED, 'type' => \App\Domain::TYPE_HOSTED, ]); $this->assertTrue($domain->isSuspended()); $code = \Artisan::call("domain:unsuspend {$domain->namespace}"); $output = trim(\Artisan::output()); $this->assertSame(0, $code); - $this->assertSame("Found domain {$domain->id}", $output); + $this->assertSame("", $output); $this->assertFalse($domain->fresh()->isSuspended()); } }