nochmal nue
This commit is contained in:
parent
2c2e34b71e
commit
6f07d70436
27 changed files with 311 additions and 1988 deletions
18
tests/Feature/Service/Config/AppNameTest.php
Normal file
18
tests/Feature/Service/Config/AppNameTest.php
Normal 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);
|
||||
|
||||
});
|
|
@ -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();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue