status)->toBe(ComponentStatus::UP) ->and($dbUp->connection)->toBe('mysql') ->and($dbUp->message)->toBeNull() ->and($dbDown->status)->toBe(ComponentStatus::DOWN) ->and($dbDown->connection)->toBe('mysql') ->and($dbDown->message)->toBe('Connection refused'); }); it('instantiates CacheCheckResult as a pure DTO', function (): void { // GIVEN $cacheUp = new CacheCheckResult( status: ComponentStatus::UP, store: 'redis', ); $cacheDown = new CacheCheckResult( status: ComponentStatus::DOWN, store: 'redis', message: 'Redis server down', ); // WHEN & THEN expect($cacheUp->status)->toBe(ComponentStatus::UP) ->and($cacheUp->store)->toBe('redis') ->and($cacheUp->message)->toBeNull() ->and($cacheDown->status)->toBe(ComponentStatus::DOWN) ->and($cacheDown->store)->toBe('redis') ->and($cacheDown->message)->toBe('Redis server down'); }); it('instantiates MailCheckResult as a pure DTO', function (): void { // GIVEN $mailSmtp = new MailCheckResult( status: ComponentStatus::UP, transport: 'smtp', ); $mailFailed = new MailCheckResult( status: ComponentStatus::DOWN, transport: 'smtp', message: 'Connection refused', ); // WHEN & THEN expect($mailSmtp->status)->toBe(ComponentStatus::UP) ->and($mailSmtp->transport)->toBe('smtp') ->and($mailSmtp->message)->toBeNull() ->and($mailFailed->status)->toBe(ComponentStatus::DOWN) ->and($mailFailed->transport)->toBe('smtp') ->and($mailFailed->message)->toBe('Connection refused'); }); it('instantiates HealthCheckResult and evaluates isHealthy', function (): void { // GIVEN $date = new \DateTimeImmutable('2026-08-21 14:30:00 UTC'); $checks = [ 'database_default' => new DatabaseCheckResult(ComponentStatus::UP, 'sqlite'), 'database_arcadia' => new DatabaseCheckResult(ComponentStatus::DOWN, 'arcadia', 'Timeout connecting to DB'), 'cache' => new CacheCheckResult(ComponentStatus::UP, 'database'), 'mail_smtp' => new MailCheckResult(ComponentStatus::UP, 'smtp'), ]; $result = new HealthCheckResult( status: HealthStatus::UNHEALTHY, timestamp: $date, checks: $checks, ); // WHEN & THEN expect($result->isHealthy())->toBeFalse() ->and($result->status)->toBe(HealthStatus::UNHEALTHY) ->and($result->timestamp)->toBe($date) ->and($result->checks['database_arcadia']->message)->toBe('Timeout connecting to DB'); }); });