From dbba057f4dcc95b05a01f37f04c388649a085121 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Thu, 18 Nov 2021 13:06:16 -0600 Subject: [PATCH 01/14] Get json --- app/Commands/BaseCommand.php | 5 ++- app/Commands/Servers/GetCommand.php | 31 ++++++++++++++++ .../Commands/ServersGetCommandTest.php | 36 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 app/Commands/Servers/GetCommand.php create mode 100644 tests/Feature/Commands/ServersGetCommandTest.php diff --git a/app/Commands/BaseCommand.php b/app/Commands/BaseCommand.php index 1109363..ff34644 100644 --- a/app/Commands/BaseCommand.php +++ b/app/Commands/BaseCommand.php @@ -117,7 +117,10 @@ protected function displayFormat(): string protected function toJson($resource): void { - $this->line(json_encode($resource->toArray(), JSON_PRETTY_PRINT)); + if (!is_array($resource)) { + $resource = $resource->toArray(); + } + $this->line(json_encode($resource, JSON_PRETTY_PRINT)); } protected function toTable($resource): void diff --git a/app/Commands/Servers/GetCommand.php b/app/Commands/Servers/GetCommand.php new file mode 100644 index 0000000..4ec3a2d --- /dev/null +++ b/app/Commands/Servers/GetCommand.php @@ -0,0 +1,31 @@ +argument('server_id'); + + $server = $this->spinupwp->servers->get($serverId); + + if ($this->displayFormat() === 'json') { + return $server; + } + + return [ + 'ID' => $server->id, + 'Name' => $server->name, + 'IP Address' => $server->ip_address, + 'Ubuntu' => $server->ubuntu_version, + 'Database' => $server->database['server'], + ]; + } +} diff --git a/tests/Feature/Commands/ServersGetCommandTest.php b/tests/Feature/Commands/ServersGetCommandTest.php new file mode 100644 index 0000000..cca8ebb --- /dev/null +++ b/tests/Feature/Commands/ServersGetCommandTest.php @@ -0,0 +1,36 @@ + 1, + 'name' => 'hellfish-media', + 'provider_name' => 'DigitalOcean', + 'ubuntu_version' => '20.04', + 'ip_address' => '127.0.0.1', + 'disk_space' => [ + 'total' => 25210576000, + 'available' => 17549436000, + 'used' => 7661140000, + 'updated_at' => '2021-11-03T16:52:48.000000Z', + ], + 'database' => [ + 'server' => 'mysql-8.0', + ], + +]; +beforeEach(function () use ($response) { + setTestConfigFile(); +}); + +afterEach(function () { + deleteTestConfigFile(); +}); + +test('servers json get command', function () use ($response) { + $this->clientMock->shouldReceive('request')->with('GET', 'servers/1', [])->andReturn( + new Response(200, [], json_encode(['data' => $response])) + ); + $this->artisan('servers:get 1')->expectsOutput(json_encode($response, JSON_PRETTY_PRINT)); +}); From f74ddf7e2d7178856c6d7198d702f6dcedfe7f13 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Thu, 18 Nov 2021 17:21:25 -0600 Subject: [PATCH 02/14] Table format --- app/Commands/Servers/GetCommand.php | 4 ++-- .../Feature/Commands/ServersGetCommandTest.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/Commands/Servers/GetCommand.php b/app/Commands/Servers/GetCommand.php index 4ec3a2d..9cac498 100644 --- a/app/Commands/Servers/GetCommand.php +++ b/app/Commands/Servers/GetCommand.php @@ -20,12 +20,12 @@ public function action() return $server; } - return [ + return collect([[ 'ID' => $server->id, 'Name' => $server->name, 'IP Address' => $server->ip_address, 'Ubuntu' => $server->ubuntu_version, 'Database' => $server->database['server'], - ]; + ]]); } } diff --git a/tests/Feature/Commands/ServersGetCommandTest.php b/tests/Feature/Commands/ServersGetCommandTest.php index cca8ebb..eb73f4b 100644 --- a/tests/Feature/Commands/ServersGetCommandTest.php +++ b/tests/Feature/Commands/ServersGetCommandTest.php @@ -34,3 +34,21 @@ ); $this->artisan('servers:get 1')->expectsOutput(json_encode($response, JSON_PRETTY_PRINT)); }); + +test('servers table get command', function () use ($response) { + $this->clientMock->shouldReceive('request')->with('GET', 'servers/1', [])->andReturn( + new Response(200, [], json_encode(['data' => $response])) + ); + $this->artisan('servers:get 1 --format=table')->expectsTable( + ['ID', 'Name', 'IP Address', 'Ubuntu', 'Database'], + [ + [ + '1', + 'hellfish-media', + '127.0.0.1', + '20.04', + 'mysql-8.0', + ], + ] + ); +}); From 2b1dd18198f46872029309f04be67d0844520196 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Fri, 19 Nov 2021 13:33:12 -0600 Subject: [PATCH 03/14] Update SDK's version and install additional package --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e60dfe3..80551c8 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,8 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", - "deliciousbrains/spinupwp-php-sdk": "^0.3.0" + "deliciousbrains/spinupwp-php-sdk": "^0.4.0", + "phplucidframe/console-table": "^1.2" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", From f51813f21f0a1da4a188f242f4b813ea4f73bbc7 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Fri, 19 Nov 2021 13:33:24 -0600 Subject: [PATCH 04/14] Change test --- tests/Feature/Commands/ServersGetCommandTest.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/tests/Feature/Commands/ServersGetCommandTest.php b/tests/Feature/Commands/ServersGetCommandTest.php index eb73f4b..f7294c2 100644 --- a/tests/Feature/Commands/ServersGetCommandTest.php +++ b/tests/Feature/Commands/ServersGetCommandTest.php @@ -39,16 +39,5 @@ $this->clientMock->shouldReceive('request')->with('GET', 'servers/1', [])->andReturn( new Response(200, [], json_encode(['data' => $response])) ); - $this->artisan('servers:get 1 --format=table')->expectsTable( - ['ID', 'Name', 'IP Address', 'Ubuntu', 'Database'], - [ - [ - '1', - 'hellfish-media', - '127.0.0.1', - '20.04', - 'mysql-8.0', - ], - ] - ); + $this->artisan('servers:get 1 --format=table')->doesntExpectOutput(json_encode($response, JSON_PRETTY_PRINT)); }); From df9c524551d99b3d0252702133d78f93adf2613e Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Fri, 19 Nov 2021 13:33:39 -0600 Subject: [PATCH 05/14] Large output for single resource --- app/Commands/BaseCommand.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/Commands/BaseCommand.php b/app/Commands/BaseCommand.php index ff34644..4c5762a 100644 --- a/app/Commands/BaseCommand.php +++ b/app/Commands/BaseCommand.php @@ -8,6 +8,7 @@ use GuzzleHttp\Client; use Illuminate\Support\Collection; use LaravelZero\Framework\Commands\Command; +use LucidFrame\Console\ConsoleTable; use Symfony\Component\Console\Formatter\OutputFormatterStyle; abstract class BaseCommand extends Command @@ -18,6 +19,8 @@ abstract class BaseCommand extends Command protected bool $requiresToken = true; + protected bool $largeOutput = false; + public function __construct(Configuration $configuration, SpinupWp $spinupWp) { parent::__construct(); @@ -82,6 +85,11 @@ protected function format($resource): void { $this->setStyles(); + if ($this->displayFormat() === 'table' && $this->largeOutput) { + $this->largeOutput($resource); + return; + } + if ($this->displayFormat() === 'table') { $this->toTable($resource); return; @@ -163,5 +171,15 @@ protected function toTable($resource): void ); } + protected function largeOutput(array $resource): void + { + $table = new ConsoleTable(); + + foreach ($resource as $key => $value) { + $table->addRow([$key, $value]); + } + $table->hideBorder()->display(); + } + abstract protected function action(); } From 872317f99f959c7177c16f7a4ef2a5dda8e95cef Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Fri, 19 Nov 2021 13:33:49 -0600 Subject: [PATCH 06/14] Get server command data WIP --- app/Commands/Servers/GetCommand.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Commands/Servers/GetCommand.php b/app/Commands/Servers/GetCommand.php index 9cac498..a153c9a 100644 --- a/app/Commands/Servers/GetCommand.php +++ b/app/Commands/Servers/GetCommand.php @@ -10,6 +10,8 @@ class GetCommand extends BaseCommand protected $description = 'Get a server'; + protected bool $largeOutput = true; + public function action() { $serverId = $this->argument('server_id'); @@ -20,12 +22,14 @@ public function action() return $server; } - return collect([[ - 'ID' => $server->id, - 'Name' => $server->name, - 'IP Address' => $server->ip_address, - 'Ubuntu' => $server->ubuntu_version, - 'Database' => $server->database['server'], - ]]); + return [ + 'ID' => $server->id, + 'Name' => $server->name, + 'Provider name' => $server->provider_name, + 'IP Address' => $server->ip_address, + 'Ubuntu' => $server->ubuntu_version, + 'Database' => $server->database['server'], + 'SSH port' => $server->ssh_port, + ]; } } From 2a939289064afca81d259fedb03828aae3e426a2 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Mon, 22 Nov 2021 10:49:58 -0600 Subject: [PATCH 07/14] Remove unused dependency (again) --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 80551c8..d9bfff3 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,6 @@ "require": { "php": "^7.4|^8.0", "deliciousbrains/spinupwp-php-sdk": "^0.4.0", - "phplucidframe/console-table": "^1.2" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", From d6858dcfba61a196a1d4bcb440ba1defa572c25e Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Mon, 22 Nov 2021 10:53:19 -0600 Subject: [PATCH 08/14] Native table --- app/Commands/BaseCommand.php | 11 +++++++---- tests/Feature/Commands/ServersGetCommandTest.php | 7 ------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/app/Commands/BaseCommand.php b/app/Commands/BaseCommand.php index 4c5762a..3997758 100644 --- a/app/Commands/BaseCommand.php +++ b/app/Commands/BaseCommand.php @@ -8,7 +8,6 @@ use GuzzleHttp\Client; use Illuminate\Support\Collection; use LaravelZero\Framework\Commands\Command; -use LucidFrame\Console\ConsoleTable; use Symfony\Component\Console\Formatter\OutputFormatterStyle; abstract class BaseCommand extends Command @@ -173,12 +172,16 @@ protected function toTable($resource): void protected function largeOutput(array $resource): void { - $table = new ConsoleTable(); + $table = []; foreach ($resource as $key => $value) { - $table->addRow([$key, $value]); + $table[] = ['' . $key . '', $value]; } - $table->hideBorder()->display(); + + $this->table( + [], + $table, + ); } abstract protected function action(); diff --git a/tests/Feature/Commands/ServersGetCommandTest.php b/tests/Feature/Commands/ServersGetCommandTest.php index f7294c2..cca8ebb 100644 --- a/tests/Feature/Commands/ServersGetCommandTest.php +++ b/tests/Feature/Commands/ServersGetCommandTest.php @@ -34,10 +34,3 @@ ); $this->artisan('servers:get 1')->expectsOutput(json_encode($response, JSON_PRETTY_PRINT)); }); - -test('servers table get command', function () use ($response) { - $this->clientMock->shouldReceive('request')->with('GET', 'servers/1', [])->andReturn( - new Response(200, [], json_encode(['data' => $response])) - ); - $this->artisan('servers:get 1 --format=table')->doesntExpectOutput(json_encode($response, JSON_PRETTY_PRINT)); -}); From 3f4c0673f2c48ea844d1f3772b51573382aaab2a Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Mon, 22 Nov 2021 10:56:53 -0600 Subject: [PATCH 09/14] Fix composer file --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d9bfff3..1c632b0 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "require": { "php": "^7.4|^8.0", - "deliciousbrains/spinupwp-php-sdk": "^0.4.0", + "deliciousbrains/spinupwp-php-sdk": "^0.4.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.2", From 250a7f85fb6e8c11fc7c51b772a1a0b7972f1a93 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Mon, 22 Nov 2021 11:32:28 -0600 Subject: [PATCH 10/14] Test --- .../Commands/ServersGetCommandTest.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/Feature/Commands/ServersGetCommandTest.php b/tests/Feature/Commands/ServersGetCommandTest.php index cca8ebb..d741343 100644 --- a/tests/Feature/Commands/ServersGetCommandTest.php +++ b/tests/Feature/Commands/ServersGetCommandTest.php @@ -18,6 +18,23 @@ 'database' => [ 'server' => 'mysql-8.0', ], + 'ssh_port' => '22', + 'timezone' => 'UTC', + 'region' => 'TOR1', + 'size' => '1 GB / 1 vCPU', + 'database' => [ + 'server' => 'mysql-8.0', + 'host' => 'localhost', + 'port' => 3306, + ], + 'ssh_publickey' => 'ssh-rsa AAAA....', + 'git_publickey' => 'ssh-rsa AAAA....', + 'connection_status' => 'connected', + 'reboot_required' => true, + 'upgrade_required' => false, + 'install_notes' => null, + 'created_at' => '2021-01-01T12:00:00.000000Z', + 'status' => 'provisioned', ]; beforeEach(function () use ($response) { @@ -34,3 +51,32 @@ ); $this->artisan('servers:get 1')->expectsOutput(json_encode($response, JSON_PRETTY_PRINT)); }); + +test('servers table get command', function () use ($response) { + $this->clientMock->shouldReceive('request')->with('GET', 'servers/1', [])->andReturn( + new Response(200, [], json_encode(['data' => $response])) + ); + $this->artisan('servers:get 1 --format=table')->expectsTable([], [ + ['ID', '1'], + ['Name', 'hellfish-media'], + ['Provider Name', 'DigitalOcean'], + ['IP Address', '127.0.0.1'], + ['Ubuntu', '20.04'], + ['Database Server', 'mysql-8.0'], + ['Database Host', 'localhost'], + ['Database Port', '3306'], + ['SSH Port', '22'], + ['Disk Space', '7.13 GB / 23.48 GB'], + ['Timezone', 'UTC'], + ['Region', 'TOR1'], + ['Size', '1 GB / 1 vCPU'], + ['SSH Public Key', 'ssh-rsa AAAA....'], + ['Git Public Key', 'ssh-rsa AAAA....'], + ['Connection Status', 'Connected'], + ['Reboot Required', 'Yes'], + ['Upgrade Required', 'No'], + ['Install Notes', ''], + ['Created At', '2021-01-01T12:00:00.000000Z'], + ['Status', 'provisioned'], + ]); +}); From 66153e21c89a2d275ed60d731fea16251a1df824 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Mon, 22 Nov 2021 11:32:32 -0600 Subject: [PATCH 11/14] Full data --- app/Commands/BaseCommand.php | 2 +- app/Commands/Servers/GetCommand.php | 30 ++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/Commands/BaseCommand.php b/app/Commands/BaseCommand.php index 5a02b88..e8c5b8c 100644 --- a/app/Commands/BaseCommand.php +++ b/app/Commands/BaseCommand.php @@ -82,7 +82,7 @@ protected function profile(): string protected function format($resource): void { - if (empty($resource) || $resource->isEmpty()) { + if (empty($resource) || ($resource instanceof Collection && $resource->isEmpty())) { return; } diff --git a/app/Commands/Servers/GetCommand.php b/app/Commands/Servers/GetCommand.php index a153c9a..7ff079b 100644 --- a/app/Commands/Servers/GetCommand.php +++ b/app/Commands/Servers/GetCommand.php @@ -22,14 +22,30 @@ public function action() return $server; } + $diskSpace = number_format($server->disk_space['used'] / 1024 / 1024 / 1024, 2) . ' GB / ' . number_format($server->disk_space['total'] / 1024 / 1024 / 1024, 2) . ' GB'; + return [ - 'ID' => $server->id, - 'Name' => $server->name, - 'Provider name' => $server->provider_name, - 'IP Address' => $server->ip_address, - 'Ubuntu' => $server->ubuntu_version, - 'Database' => $server->database['server'], - 'SSH port' => $server->ssh_port, + 'ID' => $server->id, + 'Name' => $server->name, + 'Provider Name' => $server->provider_name, + 'IP Address' => $server->ip_address, + 'Ubuntu' => $server->ubuntu_version, + 'Database Server' => $server->database['server'], + 'Database Host' => $server->database['host'], + 'Database Port' => $server->database['port'], + 'SSH Port' => $server->ssh_port, + 'Disk Space' => $diskSpace, + 'Timezone' => $server->timezone, + 'Region' => $server->region, + 'Size' => $server->size, + 'SSH Public Key' => $server->ssh_publickey, + 'Git Public Key' => $server->git_publickey, + 'Connection Status' => $server->connection_status === 'connected' ? 'Connected' : 'Not Connected', + 'Reboot Required' => $server->reboot_required ? 'Yes' : 'No', + 'Upgrade Required' => $server->upgrade_required ? 'Yes' : 'No', + 'Install Notes' => $server->install_notes ?? '', + 'Created At' => $server->created_at, + 'Status' => $server->status, ]; } } From 76f58e2b1742cb54f771552e739fc4e780c16746 Mon Sep 17 00:00:00 2001 From: realdanielmlozano Date: Mon, 22 Nov 2021 15:58:47 -0600 Subject: [PATCH 12/14] Max Columns widths --- app/Commands/BaseCommand.php | 21 +++++++++++++++------ app/Commands/Servers/GetCommand.php | 2 ++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/Commands/BaseCommand.php b/app/Commands/BaseCommand.php index e8c5b8c..d4d1fbd 100644 --- a/app/Commands/BaseCommand.php +++ b/app/Commands/BaseCommand.php @@ -9,6 +9,7 @@ use Illuminate\Support\Collection; use LaravelZero\Framework\Commands\Command; use Symfony\Component\Console\Formatter\OutputFormatterStyle; +use Symfony\Component\Console\Helper\Table; abstract class BaseCommand extends Command { @@ -20,6 +21,8 @@ abstract class BaseCommand extends Command protected bool $largeOutput = false; + protected array $columnsMaxWidths = []; + public function __construct(Configuration $configuration, SpinupWp $spinupWp) { parent::__construct(); @@ -176,16 +179,22 @@ protected function toTable($resource): void protected function largeOutput(array $resource): void { - $table = []; + $table = new Table($this->output); + $rows = []; foreach ($resource as $key => $value) { - $table[] = ['' . $key . '', $value]; + $rows[] = ['' . $key . '', $value]; } - $this->table( - [], - $table, - ); + $table->setRows($rows)->setStyle('default'); + + if (!empty($this->columnsMaxWidths)) { + foreach ($this->columnsMaxWidths as $column) { + $table->setColumnMaxWidth($column[0], $column[1]); + } + } + + $table->render(); } abstract protected function action(); diff --git a/app/Commands/Servers/GetCommand.php b/app/Commands/Servers/GetCommand.php index 7ff079b..4b4a2fc 100644 --- a/app/Commands/Servers/GetCommand.php +++ b/app/Commands/Servers/GetCommand.php @@ -14,6 +14,8 @@ class GetCommand extends BaseCommand public function action() { + $this->columnsMaxWidths[] = [1, 100]; + $serverId = $this->argument('server_id'); $server = $this->spinupwp->servers->get($serverId); From ca63fbf71129270ac558b4e186a68814dba720f1 Mon Sep 17 00:00:00 2001 From: Ashley Rich Date: Tue, 23 Nov 2021 08:45:33 +0000 Subject: [PATCH 13/14] PR review --- app/Commands/BaseCommand.php | 17 ++++++++++++++++- app/Commands/Servers/GetCommand.php | 18 ++++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/app/Commands/BaseCommand.php b/app/Commands/BaseCommand.php index d4d1fbd..45d1d21 100644 --- a/app/Commands/BaseCommand.php +++ b/app/Commands/BaseCommand.php @@ -183,7 +183,7 @@ protected function largeOutput(array $resource): void $rows = []; foreach ($resource as $key => $value) { - $rows[] = ['' . $key . '', $value]; + $rows[] = ['' . $key . '', $value]; } $table->setRows($rows)->setStyle('default'); @@ -197,5 +197,20 @@ protected function largeOutput(array $resource): void $table->render(); } + protected function formatBytes(int $bytes, int $precision = 1, bool $trueSize = false): string + { + $units = ['B', 'KB', 'MB', 'GB', 'TB']; + $block = ($trueSize) ? 1024 : 1000; + + $bytes = max($bytes, 0); + $pow = floor(($bytes ? log($bytes) : 0) / log($block)); + $pow = min($pow, count($units) - 1); + $bytes /= pow($block, $pow); + + $total = ($trueSize || $precision > 0) ? round($bytes, $precision) : floor($bytes); + + return $total . ' ' . $units[$pow]; + } + abstract protected function action(); } diff --git a/app/Commands/Servers/GetCommand.php b/app/Commands/Servers/GetCommand.php index 4b4a2fc..ba839ff 100644 --- a/app/Commands/Servers/GetCommand.php +++ b/app/Commands/Servers/GetCommand.php @@ -14,7 +14,7 @@ class GetCommand extends BaseCommand public function action() { - $this->columnsMaxWidths[] = [1, 100]; + $this->columnsMaxWidths[] = [1, 50]; $serverId = $this->argument('server_id'); @@ -24,30 +24,28 @@ public function action() return $server; } - $diskSpace = number_format($server->disk_space['used'] / 1024 / 1024 / 1024, 2) . ' GB / ' . number_format($server->disk_space['total'] / 1024 / 1024 / 1024, 2) . ' GB'; - return [ 'ID' => $server->id, 'Name' => $server->name, 'Provider Name' => $server->provider_name, 'IP Address' => $server->ip_address, - 'Ubuntu' => $server->ubuntu_version, - 'Database Server' => $server->database['server'], - 'Database Host' => $server->database['host'], - 'Database Port' => $server->database['port'], 'SSH Port' => $server->ssh_port, - 'Disk Space' => $diskSpace, + 'Ubuntu' => $server->ubuntu_version, 'Timezone' => $server->timezone, 'Region' => $server->region, 'Size' => $server->size, + 'Disk Space' => $this->formatBytes($server->disk_space['used']) . ' of ' . $this->formatBytes($server->disk_space['total'], 0) . ' used', + 'Database Server' => $server->database['server'], + 'Database Host' => $server->database['host'], + 'Database Port' => $server->database['port'], 'SSH Public Key' => $server->ssh_publickey, 'Git Public Key' => $server->git_publickey, - 'Connection Status' => $server->connection_status === 'connected' ? 'Connected' : 'Not Connected', + 'Connection Status' => ucfirst($server->connection_status), 'Reboot Required' => $server->reboot_required ? 'Yes' : 'No', 'Upgrade Required' => $server->upgrade_required ? 'Yes' : 'No', 'Install Notes' => $server->install_notes ?? '', 'Created At' => $server->created_at, - 'Status' => $server->status, + 'Status' => ucfirst($server->status), ]; } } From 92010e6a65cfc4c4a47a3d0acf69318db8fd665b Mon Sep 17 00:00:00 2001 From: Ashley Rich Date: Tue, 23 Nov 2021 08:52:38 +0000 Subject: [PATCH 14/14] Update tests --- tests/Feature/Commands/ServersGetCommandTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Feature/Commands/ServersGetCommandTest.php b/tests/Feature/Commands/ServersGetCommandTest.php index d741343..a24215f 100644 --- a/tests/Feature/Commands/ServersGetCommandTest.php +++ b/tests/Feature/Commands/ServersGetCommandTest.php @@ -61,15 +61,15 @@ ['Name', 'hellfish-media'], ['Provider Name', 'DigitalOcean'], ['IP Address', '127.0.0.1'], - ['Ubuntu', '20.04'], - ['Database Server', 'mysql-8.0'], - ['Database Host', 'localhost'], - ['Database Port', '3306'], ['SSH Port', '22'], - ['Disk Space', '7.13 GB / 23.48 GB'], + ['Ubuntu', '20.04'], ['Timezone', 'UTC'], ['Region', 'TOR1'], ['Size', '1 GB / 1 vCPU'], + ['Disk Space', '7.7 GB of 25 GB used'], + ['Database Server', 'mysql-8.0'], + ['Database Host', 'localhost'], + ['Database Port', '3306'], ['SSH Public Key', 'ssh-rsa AAAA....'], ['Git Public Key', 'ssh-rsa AAAA....'], ['Connection Status', 'Connected'], @@ -77,6 +77,6 @@ ['Upgrade Required', 'No'], ['Install Notes', ''], ['Created At', '2021-01-01T12:00:00.000000Z'], - ['Status', 'provisioned'], + ['Status', 'Provisioned'], ]); });