saufen/tests/Feature/Service/ConfigurationServiceTest.php
2025-06-09 22:05:01 +02:00

57 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
use App\Entity\SystemConfig;
use App\Enum\SystemSettingKey;
use App\Service\ConfigurationService;
test('get returns correct value', function (): void {
// Arrange
/** @var ConfigurationService $configService */
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
// Act
$value = $configService->get($key);
// Assert
expect($value)->toBe($key->defaultValue());
});
test('setConfigValue updates configuration value', function (): void {
// Arrange
/** @var ConfigurationService $configService */
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
$newValue = 'Test System Name';
// Act
$configService->set($key, $newValue);
$value = $configService->get($key);
// Assert
expect($value)->toBe($newValue);
});
test('resetAllConfigs resets all configurations to default values', function (): void {
// Arrange
/** @var ConfigurationService $configService */
$configService = $this->getContainer()->get(ConfigurationService::class);
// Set non-default values for all configs
foreach (SystemSettingKey::cases() as $key) {
$configService->set($key, 'non-default value');
}
// Act
$configService->resetAll();
// Assert
foreach (SystemSettingKey::cases() as $key) {
expect($configService->get($key))->toBe($key->defaultValue());
}
});