ldc-arcadia-api/tests/Feature/Console/Commands/ListClientsCommandTest.php
Jérémy Munsch 62c221f6b6
feat(health): add oracle probe and normalize health checks
Refactor health check DTOs around a common CheckResult contract and remove the\nlegacy HealthChecks aggregate object.\n\nAdd a dedicated /api/v1/health/oracle endpoint with response mapping, OpenAPI\nschema updates, and Bruno request coverage.\n\nAlign feature, unit, integration, architecture and OpenAPI tests with the new\nset-based checks representation and make Oracle health tests deterministic in CI.\n\nUpdate command documentation to the uwil:* command namespace.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-06 14:51:46 +02:00

98 lines
3.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Console\Commands;
use Infra\Database\Models\ApiClient;
use Presentation\Console\Commands\ListClientsCommand;
use Ramsey\Uuid\Uuid;
use Shared\Time\Utc;
covers(ListClientsCommand::class);
describe('ListClientsCommand', function (): void {
it('outputs no clients found when database is empty', function (): void {
// GIVEN
/** @var \Tests\TestCase $this */
ApiClient::query()->delete();
// WHEN
$this->artisan('uwil:arcadia:client:list')
// THEN
->expectsOutput('No clients found.')
->assertSuccessful();
});
it('outputs table of clients when clients exist', function (): void {
// GIVEN
/** @var \Tests\TestCase $this */
ApiClient::query()->delete();
$client1 = ApiClient::factory()->create([
'id' => (string) Uuid::uuid7(),
'name' => 'Production Gateway',
'slug' => 'test-' . uniqid(),
'identifier' => 'arcadia_id_' . str_repeat('a', 32),
'secret' => 'arcadia_sec_' . str_repeat('b', 86),
'is_active' => true,
]);
$client2 = ApiClient::factory()->create([
'id' => (string) Uuid::uuid7(),
'name' => 'Backup Gateway',
'slug' => 'test-' . uniqid(),
'identifier' => 'arcadia_id_' . str_repeat('c', 32),
'secret' => 'arcadia_sec_' . str_repeat('d', 86),
'is_active' => false,
]);
// WHEN
$this->artisan('uwil:arcadia:client:list')
// THEN
->expectsTable(
['ID', 'Name', 'Identifier', 'Status', 'Last Updated At'],
[
[
(string) $client1->id,
(string) $client1->name->value,
(string) $client1->identifier->value,
'Active',
Utc::toRfc3339($client1->updated_at),
],
[
(string) $client2->id,
(string) $client2->name->value,
(string) $client2->identifier->value,
'Inactive',
Utc::toRfc3339($client2->updated_at),
],
]
)
->expectsOutput('Showing page 1/1 (Total: 2 client(s))')
->assertSuccessful();
});
it('respects pagination options', function (): void {
// GIVEN
/** @var \Tests\TestCase $this */
ApiClient::query()->delete();
for ($i = 1; $i <= 3; $i++) {
ApiClient::factory()->create([
'id' => (string) Uuid::uuid7(),
'name' => "Client {$i}",
'slug' => 'test-' . uniqid(),
'identifier' => 'arcadia_id_' . str_repeat((string) $i, 32),
'secret' => 'arcadia_sec_' . str_repeat((string) $i, 86),
'is_active' => true,
]);
}
// WHEN
$this->artisan('uwil:arcadia:client:list', ['--page' => '2', '--per-page' => '2'])
// THEN
->expectsOutput('Showing page 2/2 (Total: 3 client(s))')
->assertSuccessful();
});
});