testitest
This commit is contained in:
parent
43ca79f650
commit
66c4c1fe4f
30 changed files with 4443 additions and 184 deletions
86
tests/Feature/Service/Config/ConfigServicesTest.php
Normal file
86
tests/Feature/Service/Config/ConfigServicesTest.php
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
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 () {
|
||||
// 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 () {
|
||||
// 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 () {
|
||||
// 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 () {
|
||||
// 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 () {
|
||||
// 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