Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2571847
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
View Options
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 @@
<?php
namespace App\Console\Commands\Domain;
use App\Console\Command;
class SuspendCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'domain:suspend {domain}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Suspend a domain';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$domain = $this->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 @@
<?php
namespace App\Console\Commands\Domain;
use App\Console\Command;
class UnsuspendCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'domain:unsuspend {domain}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Remove a domain suspension';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$domain = $this->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 @@
<?php
namespace App\Console\Development;
use App\Domain;
use Illuminate\Console\Command;
class DomainStatus extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'domain:status {domain} {--add=} {--del=}';
/**
* The console command description.
*
* @var string
*/
protected $description = "Set/get a domain's status.";
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$domain = Domain::where('namespace', $this->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 @@
<?php
namespace Tests\Feature\Console\Domain;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SuspendTest 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
*/
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 @@
<?php
namespace Tests\Feature\Console\Domain;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UnsuspendTest 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
*/
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());
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Thu, Mar 19, 9:05 AM (22 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
457716
Default Alt Text
(7 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment