Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117921200
D3650.1775430210.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None
D3650.1775430210.diff
View Options
diff --git a/src/app/Console/Commands/Domain/StatusCommand.php b/src/app/Console/Commands/Domain/StatusCommand.php
--- a/src/app/Console/Commands/Domain/StatusCommand.php
+++ b/src/app/Console/Commands/Domain/StatusCommand.php
@@ -28,7 +28,7 @@
*/
public function handle()
{
- $domain = $this->getDomain($this->argument('domain'));
+ $domain = $this->getDomain($this->argument('domain'), true);
if (!$domain) {
$this->error("Domain not found.");
@@ -39,17 +39,25 @@
'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,
+ 'verified' => Domain::STATUS_VERIFIED,
+ 'ldapReady' => Domain::STATUS_LDAP_READY,
];
- foreach ($statuses as $text => $bit) {
- $func = 'is' . \ucfirst($text);
+ $domain_state = [];
- $this->info(sprintf("%d %s: %s", $bit, $text, $domain->$func()));
+ foreach ($statuses as $text => $bit) {
+ if ($text == 'deleted') {
+ $status = $domain->trashed();
+ } else {
+ $status = $domain->{'is' . \ucfirst($text)}();
+ }
+
+ if ($status) {
+ $domain_state[] = "$text ($bit)";
+ }
}
- $this->info("In total: {$domain->status}");
+ $this->info("Status ({$domain->status}): " . \implode(', ', $domain_state));
}
}
diff --git a/src/app/Console/Commands/User/StatusCommand.php b/src/app/Console/Commands/User/StatusCommand.php
--- a/src/app/Console/Commands/User/StatusCommand.php
+++ b/src/app/Console/Commands/User/StatusCommand.php
@@ -32,7 +32,6 @@
if (!$user) {
$this->error("User not found.");
- $this->error("Try ./artisan scalpel:user:read --attr=email --attr=tenant_id " . $this->argument('user'));
return 1;
}
@@ -47,13 +46,18 @@
$user_state = [];
- foreach (\array_keys($statuses) as $state) {
- $func = 'is' . \ucfirst($state);
- if ($user->$func()) {
- $user_state[] = $state;
+ foreach ($statuses as $text => $bit) {
+ if ($text == 'deleted') {
+ $status = $user->trashed();
+ } else {
+ $status = $user->{'is' . \ucfirst($text)}();
+ }
+
+ if ($status) {
+ $user_state[] = "$text ($bit)";
}
}
- $this->info("Status: " . \implode(',', $user_state));
+ $this->info("Status ({$user->status}): " . \implode(', ', $user_state));
}
}
diff --git a/src/tests/Feature/Console/Domain/StatusTest.php b/src/tests/Feature/Console/Domain/StatusTest.php
--- a/src/tests/Feature/Console/Domain/StatusTest.php
+++ b/src/tests/Feature/Console/Domain/StatusTest.php
@@ -2,29 +2,63 @@
namespace Tests\Feature\Console\Domain;
+use Illuminate\Support\Facades\Queue;
use Tests\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
*/
public function testHandle(): void
{
+ Queue::fake();
+
// Non-existing domain
$code = \Artisan::call("domain:status unknown.org");
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
$this->assertSame("Domain not found.", $output);
-
// Existing domain
$code = \Artisan::call("domain:status kolab.org");
$output = trim(\Artisan::output());
$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);
}
}
diff --git a/src/tests/Feature/Console/User/StatusTest.php b/src/tests/Feature/Console/User/StatusTest.php
--- a/src/tests/Feature/Console/User/StatusTest.php
+++ b/src/tests/Feature/Console/User/StatusTest.php
@@ -2,28 +2,60 @@
namespace Tests\Feature\Console\User;
+use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class StatusTest extends TestCase
{
+ /**
+ * {@inheritDoc}
+ */
+ public function setUp(): void
+ {
+ parent::setUp();
+
+ $this->deleteTestUser('user@force-delete.com');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function tearDown(): void
+ {
+ $this->deleteTestUser('user@force-delete.com');
+
+ parent::tearDown();
+ }
+
/**
* Test command runs
*/
public function testHandle(): void
{
+ Queue::fake();
+
+ // Non-existing user
$code = \Artisan::call("user:status unknown");
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
- $this->assertSame(
- "User not found.\nTry ./artisan scalpel:user:read --attr=email --attr=tenant_id unknown",
- $output
- );
+ $this->assertSame("User not found.", $output);
+ // Existing user
$code = \Artisan::call("user:status john@kolab.org");
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertSame("Status: active,ldapReady,imapReady", $output);
+ $this->assertSame("Status (51): active (2), ldapReady (16), imapReady (32)", $output);
+
+ $user = $this->getTestUser('user@force-delete.com');
+ $user->delete();
+
+ // Deleted user
+ $code = \Artisan::call("user:status {$user->email}");
+ $output = trim(\Artisan::output());
+
+ $this->assertSame(0, $code);
+ $this->assertSame("Status (3): active (2), deleted (8)", $output);
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Apr 5, 11:03 PM (21 h, 29 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18834861
Default Alt Text
D3650.1775430210.diff (6 KB)
Attached To
Mode
D3650: Improve domain:status and user:status commands
Attached
Detach File
Event Timeline