refactor: reorganise Service/ into Provider/ and Renderer/ sub-namespaces
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>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\Unit\Service\Provider;
|
||||
|
||||
use App\Service\Provider\ProviderErrorCode;
|
||||
use App\Service\Provider\ProviderHealthChecker;
|
||||
use App\Service\Provider\ProviderInterface;
|
||||
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(ProviderHealthChecker::class)]
|
||||
final class ProviderHealthCheckerTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function it_returns_ok_when_all_providers_are_healthy(): void
|
||||
{
|
||||
$provider = $this->createStub(ProviderInterface::class);
|
||||
$provider->method('probe')->willReturn(new ProviderStatus('test', ProviderStatusType::Ok));
|
||||
|
||||
$result = (new ProviderHealthChecker([$provider]))->check();
|
||||
|
||||
$this->assertSame('ok', $result['status']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_returns_degraded_when_a_provider_has_an_error(): void
|
||||
{
|
||||
$provider = $this->createStub(ProviderInterface::class);
|
||||
$provider->method('probe')->willReturn(
|
||||
new ProviderStatus('test', ProviderStatusType::Error, ProviderErrorCode::AuthFailed, 'Invalid token'),
|
||||
);
|
||||
|
||||
$result = (new ProviderHealthChecker([$provider]))->check();
|
||||
|
||||
$this->assertSame('degraded', $result['status']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_does_not_degrade_when_a_provider_is_not_configured(): void
|
||||
{
|
||||
$provider = $this->createStub(ProviderInterface::class);
|
||||
$provider->method('probe')->willReturn(new ProviderStatus('test', ProviderStatusType::NotConfigured));
|
||||
|
||||
$result = (new ProviderHealthChecker([$provider]))->check();
|
||||
|
||||
$this->assertSame('ok', $result['status']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_indexes_provider_statuses_by_name(): void
|
||||
{
|
||||
$provider = $this->createStub(ProviderInterface::class);
|
||||
$provider->method('probe')->willReturn(new ProviderStatus('github', ProviderStatusType::Ok));
|
||||
|
||||
$result = (new ProviderHealthChecker([$provider]))->check();
|
||||
|
||||
$this->assertArrayHasKey('github', $result['providers']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_returns_ok_with_no_providers(): void
|
||||
{
|
||||
$result = (new ProviderHealthChecker([]))->check();
|
||||
|
||||
$this->assertSame('ok', $result['status']);
|
||||
$this->assertSame([], $result['providers']);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function it_includes_all_provider_statuses_in_output(): void
|
||||
{
|
||||
$github = $this->createStub(ProviderInterface::class);
|
||||
$github->method('probe')->willReturn(new ProviderStatus('github', ProviderStatusType::Ok));
|
||||
|
||||
$gitlab = $this->createStub(ProviderInterface::class);
|
||||
$gitlab->method('probe')->willReturn(new ProviderStatus('gitlab', ProviderStatusType::NotConfigured));
|
||||
|
||||
$result = (new ProviderHealthChecker([$github, $gitlab]))->check();
|
||||
|
||||
$this->assertArrayHasKey('github', $result['providers']);
|
||||
$this->assertArrayHasKey('gitlab', $result['providers']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user