This commit is contained in:
lubiana 2025-06-09 19:56:08 +02:00
parent 66c4c1fe4f
commit 2c2e34b71e
Signed by: lubiana
SSH key fingerprint: SHA256:vW1EA0fRR3Fw+dD/sM0K+x3Il2gSry6YRYHqOeQwrfk
42 changed files with 910 additions and 939 deletions

View file

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use App\Entity\DrinkType;
use App\Entity\InventoryRecord;
use App\Enum\StockState;
@ -11,7 +13,7 @@ use App\Service\InventoryService;
use App\ValueObject\DrinkStock;
use Doctrine\ORM\EntityManagerInterface;
test('getAllInventoryRecords returns all inventory records', function () {
test('getAllInventoryRecords returns all inventory records', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
@ -22,7 +24,7 @@ test('getAllInventoryRecords returns all inventory records', function () {
expect($records)->toBeArray();
});
test('getInventoryRecordsByDrinkType returns records for specific drink type', function () {
test('getInventoryRecordsByDrinkType returns records for specific drink type', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -56,7 +58,7 @@ test('getInventoryRecordsByDrinkType returns records for specific drink type', f
expect($records[0]->getDrinkType()->getId())->toBe($drinkType->getId());
});
test('getLatestInventoryRecord returns latest record for drink type', function () {
test('getLatestInventoryRecord returns latest record for drink type', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -97,7 +99,7 @@ test('getLatestInventoryRecord returns latest record for drink type', function (
expect($latestRecord->getQuantity())->toBe(12);
});
test('getLatestInventoryRecord creates new record if none exists', function () {
test('getLatestInventoryRecord creates new record if none exists', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -125,7 +127,7 @@ test('getLatestInventoryRecord creates new record if none exists', function () {
expect($latestRecord->getQuantity())->toBe(0);
});
test('getCurrentStockLevel returns correct stock level', function () {
test('getCurrentStockLevel returns correct stock level', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -151,7 +153,7 @@ test('getCurrentStockLevel returns correct stock level', function () {
expect($stockLevel)->toBe(15);
});
test('updateStockLevel creates new inventory record', function () {
test('updateStockLevel creates new inventory record', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -180,7 +182,7 @@ test('updateStockLevel creates new inventory record', function () {
expect($currentLevel)->toBe($newQuantity);
});
test('getAllDrinkTypesWithStockLevels returns all drink types with stock', function () {
test('getAllDrinkTypesWithStockLevels returns all drink types with stock', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -227,7 +229,7 @@ test('getAllDrinkTypesWithStockLevels returns all drink types with stock', funct
}
});
test('getDrinkStock returns correct DrinkStock object with CRITICAL state', function () {
test('getDrinkStock returns correct DrinkStock object with CRITICAL state', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -259,7 +261,7 @@ test('getDrinkStock returns correct DrinkStock object with CRITICAL state', func
expect($drinkStock->stock)->toBe(StockState::CRITICAL);
});
test('getDrinkStock returns correct DrinkStock object with LOW state', function () {
test('getDrinkStock returns correct DrinkStock object with LOW state', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -267,7 +269,7 @@ test('getDrinkStock returns correct DrinkStock object with LOW state', function
// Set low stock multiplier
$lowStockMultiplier = 0.3;
$configService->setConfigValue(SystemSettingKey::STOCK_LOW_MULTIPLIER, (string)$lowStockMultiplier);
$configService->setConfigValue(SystemSettingKey::STOCK_LOW_MULTIPLIER, (string) $lowStockMultiplier);
// Create a drink type with low quantity
$desiredStock = 10;
@ -278,7 +280,7 @@ test('getDrinkStock returns correct DrinkStock object with LOW state', function
$em->flush();
// Create inventory record with low quantity (between 0 and lowStockMultiplier * desiredStock)
$lowQuantity = (int)($desiredStock * $lowStockMultiplier) - 1;
$lowQuantity = (int) ($desiredStock * $lowStockMultiplier) - 1;
$record = new InventoryRecord();
$record->setDrinkType($drinkType);
$record->setQuantity($lowQuantity);
@ -294,7 +296,7 @@ test('getDrinkStock returns correct DrinkStock object with LOW state', function
expect($drinkStock->stock)->toBe(StockState::LOW);
});
test('getDrinkStock returns correct DrinkStock object with NORMAL state', function () {
test('getDrinkStock returns correct DrinkStock object with NORMAL state', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -302,7 +304,7 @@ test('getDrinkStock returns correct DrinkStock object with NORMAL state', functi
// Set low stock multiplier
$lowStockMultiplier = 0.3;
$configService->setConfigValue(SystemSettingKey::STOCK_LOW_MULTIPLIER, (string)$lowStockMultiplier);
$configService->setConfigValue(SystemSettingKey::STOCK_LOW_MULTIPLIER, (string) $lowStockMultiplier);
// Create a drink type with normal quantity
$desiredStock = 10;
@ -313,7 +315,7 @@ test('getDrinkStock returns correct DrinkStock object with NORMAL state', functi
$em->flush();
// Create inventory record with normal quantity (between lowStockMultiplier * desiredStock and desiredStock)
$normalQuantity = (int)($desiredStock * $lowStockMultiplier) + 1;
$normalQuantity = (int) ($desiredStock * $lowStockMultiplier) + 1;
$record = new InventoryRecord();
$record->setDrinkType($drinkType);
$record->setQuantity($normalQuantity);
@ -329,7 +331,7 @@ test('getDrinkStock returns correct DrinkStock object with NORMAL state', functi
expect($drinkStock->stock)->toBe(StockState::NORMAL);
});
test('getDrinkStock returns correct DrinkStock object with HIGH state', function () {
test('getDrinkStock returns correct DrinkStock object with HIGH state', function (): void {
// Arrange
$inventoryService = $this->getContainer()->get(InventoryService::class);
$configService = $this->getContainer()->get(ConfigurationService::class);