2f3268c0b7
Move all provider-related classes, enums, interface and trait into App\Service\Provider; move SvgRenderer into App\Service\Renderer. ContributionAggregator stays at the Service root as the orchestrator. Test namespaces and use statements updated to match. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
65 lines
1.9 KiB
PHP
65 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Tests\Unit\Service\Provider;
|
|
|
|
use App\Service\Provider\ProviderErrorCode;
|
|
use App\Service\Provider\ProviderStatus;
|
|
use App\Service\Provider\ProviderStatusType;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
#[CoversClass(ProviderStatus::class)]
|
|
final class ProviderStatusTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function it_serializes_ok_status(): void
|
|
{
|
|
$status = new ProviderStatus('github', ProviderStatusType::Ok);
|
|
|
|
$this->assertSame(['status' => 'ok'], $status->toArray());
|
|
}
|
|
|
|
#[Test]
|
|
public function it_serializes_not_configured_status(): void
|
|
{
|
|
$status = new ProviderStatus('github', ProviderStatusType::NotConfigured);
|
|
|
|
$this->assertSame(['status' => 'not_configured'], $status->toArray());
|
|
}
|
|
|
|
#[Test]
|
|
public function it_serializes_error_status_with_code_and_message(): void
|
|
{
|
|
$status = new ProviderStatus('github', ProviderStatusType::Error, ProviderErrorCode::AuthFailed, 'Token expired');
|
|
|
|
$this->assertSame([
|
|
'status' => 'error',
|
|
'error' => 'auth_failed',
|
|
'message' => 'Token expired',
|
|
], $status->toArray());
|
|
}
|
|
|
|
#[Test]
|
|
public function it_omits_null_error_fields_from_array(): void
|
|
{
|
|
$status = new ProviderStatus('github', ProviderStatusType::Ok);
|
|
|
|
$array = $status->toArray();
|
|
|
|
$this->assertArrayNotHasKey('error', $array);
|
|
$this->assertArrayNotHasKey('message', $array);
|
|
}
|
|
|
|
#[Test]
|
|
public function it_exposes_typed_status_property(): void
|
|
{
|
|
$status = new ProviderStatus('github', ProviderStatusType::Error, ProviderErrorCode::Unknown, 'msg');
|
|
|
|
$this->assertSame(ProviderStatusType::Error, $status->status);
|
|
$this->assertSame(ProviderErrorCode::Unknown, $status->error);
|
|
}
|
|
}
|