nochmal nue

This commit is contained in:
lubiana 2025-06-09 22:05:01 +02:00
parent 2c2e34b71e
commit 6f07d70436
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
27 changed files with 311 additions and 1988 deletions

View file

@ -0,0 +1,18 @@
<?php
use App\Enum\SystemSettingKey;
use App\Service\Config\AppName;
use App\Service\ConfigurationService;
test('it returns the system name from configuration service', function () {
/** @var ConfigurationService $configService */
$configService = $this->getContainer()->get(ConfigurationService::class);
$appName = new AppName($configService);
expect((string)$appName)->toBe(SystemSettingKey::SYSTEM_NAME->defaultValue());
$expected = 'Test System Name';
$configService->set(SystemSettingKey::SYSTEM_NAME, $expected);
expect((string)$appName)->toBe($expected);
});

View file

@ -1,88 +0,0 @@
<?php
declare(strict_types=1);
use App\Entity\SystemConfig;
use App\Enum\SystemSettingKey;
use App\Service\Config\AppName;
use App\Service\Config\LowStockMultiplier;
use App\Service\ConfigurationService;
test('AppName returns system name from configuration', function (): void {
// Arrange
$appName = $this->getContainer()->get(AppName::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
$testSystemName = 'Test System Name';
// Set a custom system name
$configService->setConfigValue(SystemSettingKey::SYSTEM_NAME, $testSystemName);
// Act
$result = (string) $appName;
// Assert
expect($result)->toBe($testSystemName);
});
test('AppName returns default system name when not configured', function (): void {
// Arrange
$appName = $this->getContainer()->get(AppName::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
// Reset to default value
$configService->setDefaultValue(SystemSettingKey::SYSTEM_NAME);
// Act
$result = (string) $appName;
// Assert
expect($result)->toBe(SystemConfig::DEFAULT_SYSTEM_NAME);
});
test('LowStockMultiplier returns multiplier from configuration', function (): void {
// Arrange
$lowStockMultiplier = $this->getContainer()->get(LowStockMultiplier::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
$testMultiplier = '0.5';
// Set a custom multiplier
$configService->setConfigValue(SystemSettingKey::STOCK_LOW_MULTIPLIER, $testMultiplier);
// Act
$result = $lowStockMultiplier->getValue();
// Assert
expect($result)->toBe((float) $testMultiplier);
});
test('LowStockMultiplier returns default multiplier when not configured', function (): void {
// Arrange
$lowStockMultiplier = $this->getContainer()->get(LowStockMultiplier::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
// Reset to default value
$configService->setDefaultValue(SystemSettingKey::STOCK_LOW_MULTIPLIER);
// Act
$result = $lowStockMultiplier->getValue();
// Assert
expect($result)->toBe((float) SystemConfig::DEFAULT_STOCK_LOW_MULTIPLIER);
});
test('LowStockMultiplier converts string value to float', function (): void {
// Arrange
$lowStockMultiplier = $this->getContainer()->get(LowStockMultiplier::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
$testMultiplier = '0.75';
// Set a custom multiplier
$configService->setConfigValue(SystemSettingKey::STOCK_LOW_MULTIPLIER, $testMultiplier);
// Act
$result = $lowStockMultiplier->getValue();
// Assert
expect($result)->toBe(0.75);
expect($result)->toBeFloat();
});