ldc-arcadia-api/tests/Feature/Console/Commands/CreateClientCommandTest.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

73 lines
2.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Console\Commands;
use Infra\Database\Models\ApiClient;
use Presentation\Console\Commands\CreateClientCommand;
covers(CreateClientCommand::class);
describe('CreateClientCommand', function (): void {
it('creates a client through the wizard', function (): void {
// GIVEN
/** @var \Tests\TestCase $this */
$clientName = 'Production Gateway';
// WHEN
$this->artisan('uwil:arcadia:client:create')
// THEN
->expectsQuestion('Client name (e.g. "Ones Branding website")', $clientName)
->expectsConfirmation('Create this API client?', 'yes')
->expectsOutputToContain("API client '{$clientName}' created successfully.")
->expectsOutputToContain('Store the secret securely')
->assertSuccessful();
$client = ApiClient::query()->where('name', $clientName)->first();
expect($client)->not->toBeNull()
->and($client->is_active)->toBeTrue()
->and($client->name->value)->toBe($clientName)
->and((string) $client->identifier->value)->toStartWith('arcadia_id_')
->and((string) $client->secret->value)->toStartWith('arcadia_sec_');
});
it('aborts when user cancels confirmation', function (): void {
// GIVEN
/** @var \Tests\TestCase $this */
$clientName = 'Cancelled Gateway';
// WHEN
$this->artisan('uwil:arcadia:client:create')
// THEN
->expectsQuestion('Client name (e.g. "Ones Branding website")', $clientName)
->expectsConfirmation('Create this API client?', 'no')
->expectsOutput('Client creation cancelled.')
->assertSuccessful();
$client = ApiClient::query()->where('name', $clientName)->first();
expect($client)->toBeNull();
});
it('fails when an empty name is provided', function (): void {
// GIVEN & WHEN & THEN
/** @var \Tests\TestCase $this */
$this->artisan('uwil:arcadia:client:create')
->expectsQuestion('Client name (e.g. "Ones Branding website")', '')
->assertFailed();
});
it('fails when the client name already exists', function (): void {
// GIVEN
/** @var \Tests\TestCase $this */
ApiClient::factory()->create([
'name' => 'Existing Gateway',
'slug' => 'existing-gateway',
]);
// WHEN & THEN
$this->artisan('uwil:arcadia:client:create')
->expectsQuestion('Client name (e.g. "Ones Branding website")', 'Existing Gateway')
->assertFailed();
});
});