ldc-arcadia-api/tests/Integration/Infra/Providers/ConfigServiceProviderTest.php

84 lines
3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Integration\Infra\Providers;
use Application\Arcadia\Config\AppConfig;
use Application\Arcadia\Config\ThrottlingConfig;
use Application\Security\Config\HmacAuthConfig;
use Application\Security\Config\SecurityAlertMailConfig;
use Infra\Config\ArcadiaStorageConfig;
use Infra\Providers\ConfigServiceProvider;
use Psr\Clock\ClockInterface;
use Shared\Time\Clock;
use Shared\Time\SystemClock;
use Tests\TestCase;
uses(TestCase::class);
covers(ConfigServiceProvider::class);
describe('ConfigServiceProvider Integration Tests', function (): void {
it('resolves SecurityAlertMailConfig with typed Email VO', function (): void {
// WHEN
$config = resolve(SecurityAlertMailConfig::class);
// THEN
expect($config)->toBeInstanceOf(SecurityAlertMailConfig::class)
->and($config->recipientEmail->value)->not->toBeEmpty();
});
it('resolves HmacAuthConfig with dev client credentials', function (): void {
// WHEN
$config = resolve(HmacAuthConfig::class);
// THEN
expect($config)->toBeInstanceOf(HmacAuthConfig::class)
->and($config->devClient)->not->toBeNull()
->and($config->devClient?->name->value)->toBe('Arcadia Dev Test Client');
});
it('resolves ThrottlingConfig with typed RequestsPerMinute VOs', function (): void {
// WHEN
$config = resolve(ThrottlingConfig::class);
// THEN
expect($config)->toBeInstanceOf(ThrottlingConfig::class)
->and($config->webLimit->toInt())->toBeGreaterThanOrEqual(1)
->and($config->apiV1Limit->toInt())->toBeGreaterThanOrEqual(1);
});
it('resolves AppConfig with typed timezone and locale VOs', function (): void {
// WHEN
$config = resolve(AppConfig::class);
// THEN
expect($config)->toBeInstanceOf(AppConfig::class)
->and($config->name->value)->not->toBeEmpty()
->and($config->timezone->name)->toBe('UTC')
->and($config->locale->value())->not->toBeEmpty()
->and($config->fallbackLocale->value())->not->toBeEmpty();
});
it('resolves ArcadiaStorageConfig with database and cache settings', function (): void {
// WHEN
$config = resolve(ArcadiaStorageConfig::class);
// THEN
expect($config)->toBeInstanceOf(ArcadiaStorageConfig::class)
->and($config->cacheStore)->not->toBeEmpty()
->and($config->databaseConnection)->not->toBeEmpty();
});
it('resolves PSR-20 ClockInterface and Clock service singleton configured with AppConfig timezone', function (): void {
// WHEN
$clock = resolve(Clock::class);
$clockInterface = resolve(ClockInterface::class);
// THEN
expect($clock)->toBeInstanceOf(SystemClock::class)
->and($clockInterface)->toBeInstanceOf(SystemClock::class)
->and($clock->now()->getTimezone()->getName())->toBe('UTC');
});
});