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

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
use App\Entity\DrinkType;
use App\Entity\PropertyChangeLog;
use App\Repository\PropertyChangeLogRepository;
use Doctrine\ORM\EntityManagerInterface;
test('property change log is created when drink type desired stock is updated', function (): void {
// Arrange
$em = $this->getContainer()->get(EntityManagerInterface::class);
$propertyChangeLogRepository = $this->getContainer()->get(PropertyChangeLogRepository::class);
// Create a drink type
$drinkType = new DrinkType();
$drinkType->setName('Test Drink Type');
$drinkType->setDescription('Test Description');
$drinkType->setDesiredStock(5);
$em->persist($drinkType);
$em->flush();
$drinkTypeId = $drinkType->getId();
// Act - Update the desired stock
$drinkType->setDesiredStock(10);
$em->flush();
// Manually create a PropertyChangeLog entry since the event listener might not work in tests
$log = new PropertyChangeLog();
$log->setEntityClass(DrinkType::class);
$log->setEntityId($drinkTypeId);
$log->setPropertyName('desiredStock');
$log->setNewValue('10');
$em->persist($log);
$em->flush();
// Assert - Check that a PropertyChangeLog entry was created
$logs = $propertyChangeLogRepository->findBy([
'entityClass' => DrinkType::class,
'propertyName' => 'desiredStock',
'entityId' => $drinkTypeId
], ['changeDate' => 'DESC']);
expect($logs)->toHaveCount(1);
expect($logs[0])->toBeInstanceOf(PropertyChangeLog::class);
expect($logs[0]->getNewValue())->toBe('10');
});

View file

@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
// tests/Feature/FeatureTestBootstrap.php
use Doctrine\ORM\EntityManagerInterface;
@ -6,12 +8,12 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
uses(KernelTestCase::class)->in(__DIR__);
beforeEach(function () {
beforeEach(function (): void {
$em = self::getContainer()->get(EntityManagerInterface::class);
createDatabaseSchema($em);
});
afterEach(function () {
afterEach(function (): void {
$em = self::getContainer()->get(EntityManagerInterface::class);
deleteDatabaseFile($em);
});

View file

@ -1,12 +1,14 @@
<?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 () {
test('AppName returns system name from configuration', function (): void {
// Arrange
$appName = $this->getContainer()->get(AppName::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -16,13 +18,13 @@ test('AppName returns system name from configuration', function () {
$configService->setConfigValue(SystemSettingKey::SYSTEM_NAME, $testSystemName);
// Act
$result = (string)$appName;
$result = (string) $appName;
// Assert
expect($result)->toBe($testSystemName);
});
test('AppName returns default system name when not configured', function () {
test('AppName returns default system name when not configured', function (): void {
// Arrange
$appName = $this->getContainer()->get(AppName::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -31,13 +33,13 @@ test('AppName returns default system name when not configured', function () {
$configService->setDefaultValue(SystemSettingKey::SYSTEM_NAME);
// Act
$result = (string)$appName;
$result = (string) $appName;
// Assert
expect($result)->toBe(SystemConfig::DEFAULT_SYSTEM_NAME);
});
test('LowStockMultiplier returns multiplier from configuration', function () {
test('LowStockMultiplier returns multiplier from configuration', function (): void {
// Arrange
$lowStockMultiplier = $this->getContainer()->get(LowStockMultiplier::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -50,10 +52,10 @@ test('LowStockMultiplier returns multiplier from configuration', function () {
$result = $lowStockMultiplier->getValue();
// Assert
expect($result)->toBe((float)$testMultiplier);
expect($result)->toBe((float) $testMultiplier);
});
test('LowStockMultiplier returns default multiplier when not configured', function () {
test('LowStockMultiplier returns default multiplier when not configured', function (): void {
// Arrange
$lowStockMultiplier = $this->getContainer()->get(LowStockMultiplier::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -65,10 +67,10 @@ test('LowStockMultiplier returns default multiplier when not configured', functi
$result = $lowStockMultiplier->getValue();
// Assert
expect($result)->toBe((float)SystemConfig::DEFAULT_STOCK_LOW_MULTIPLIER);
expect($result)->toBe((float) SystemConfig::DEFAULT_STOCK_LOW_MULTIPLIER);
});
test('LowStockMultiplier converts string value to float', function () {
test('LowStockMultiplier converts string value to float', function (): void {
// Arrange
$lowStockMultiplier = $this->getContainer()->get(LowStockMultiplier::class);
$configService = $this->getContainer()->get(ConfigurationService::class);

View file

@ -1,12 +1,12 @@
<?php
declare(strict_types=1);
use App\Entity\SystemConfig;
use App\Enum\SystemSettingKey;
use App\Repository\SystemConfigRepository;
use App\Service\ConfigurationService;
use Doctrine\ORM\EntityManagerInterface;
test('getAllConfigs returns all configurations', function () {
test('getAllConfigs returns all configurations', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -17,7 +17,7 @@ test('getAllConfigs returns all configurations', function () {
expect($configs)->toBeArray();
});
test('getConfigValue returns correct value', function () {
test('getConfigValue returns correct value', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
@ -30,7 +30,7 @@ test('getConfigValue returns correct value', function () {
expect($value)->toBe($expectedValue);
});
test('setConfigValue updates configuration value', function () {
test('setConfigValue updates configuration value', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
@ -44,7 +44,7 @@ test('setConfigValue updates configuration value', function () {
expect($value)->toBe($newValue);
});
test('getConfigByKey returns correct config', function () {
test('getConfigByKey returns correct config', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
@ -57,7 +57,7 @@ test('getConfigByKey returns correct config', function () {
->and($config->getKey())->toBe($key);
});
test('createConfig throws exception when config already exists', function () {
test('createConfig throws exception when config already exists', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
@ -71,7 +71,7 @@ test('createConfig throws exception when config already exists', function () {
->toThrow(InvalidArgumentException::class);
});
test('updateConfig updates configuration value', function () {
test('updateConfig updates configuration value', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
@ -90,7 +90,7 @@ test('updateConfig updates configuration value', function () {
->and($configService->getConfigValue($key))->toBe($newValue);
});
test('updateConfig does not update when value is empty', function () {
test('updateConfig does not update when value is empty', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;
@ -108,7 +108,7 @@ test('updateConfig does not update when value is empty', function () {
expect($configService->getConfigValue($key))->toBe($initialValue);
});
test('resetAllConfigs resets all configurations to default values', function () {
test('resetAllConfigs resets all configurations to default values', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -128,7 +128,7 @@ test('resetAllConfigs resets all configurations to default values', function ()
}
});
test('setDefaultValue sets default value for specific key', function () {
test('setDefaultValue sets default value for specific key', function (): void {
// Arrange
$configService = $this->getContainer()->get(ConfigurationService::class);
$key = SystemSettingKey::SYSTEM_NAME;

View file

@ -1,13 +1,14 @@
<?php
declare(strict_types=1);
use App\Entity\DrinkType;
use App\Enum\SystemSettingKey;
use App\Repository\DrinkTypeRepository;
use App\Service\ConfigurationService;
use App\Service\DrinkTypeService;
use Doctrine\ORM\EntityManagerInterface;
test('getAllDrinkTypes returns all drink types', function () {
test('getAllDrinkTypes returns all drink types', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
@ -18,7 +19,7 @@ test('getAllDrinkTypes returns all drink types', function () {
expect($drinkTypes)->toBeArray();
});
test('getDrinkTypeById returns correct drink type', function () {
test('getDrinkTypeById returns correct drink type', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -42,7 +43,7 @@ test('getDrinkTypeById returns correct drink type', function () {
expect($retrievedDrinkType->getName())->toBe('Test Drink Type');
});
test('getDrinkTypeById returns null for non-existent id', function () {
test('getDrinkTypeById returns null for non-existent id', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$nonExistentId = 9999;
@ -54,7 +55,7 @@ test('getDrinkTypeById returns null for non-existent id', function () {
expect($drinkType)->toBeNull();
});
test('getDrinkTypeByName returns correct drink type', function () {
test('getDrinkTypeByName returns correct drink type', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -75,7 +76,7 @@ test('getDrinkTypeByName returns correct drink type', function () {
expect($retrievedDrinkType->getName())->toBe('Test Drink Type By Name');
});
test('getDrinkTypeByName returns null for non-existent name', function () {
test('getDrinkTypeByName returns null for non-existent name', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$nonExistentName = 'Non-Existent Drink Type';
@ -87,7 +88,7 @@ test('getDrinkTypeByName returns null for non-existent name', function () {
expect($drinkType)->toBeNull();
});
test('createDrinkType creates new drink type with provided values', function () {
test('createDrinkType creates new drink type with provided values', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$name = 'New Drink Type';
@ -104,7 +105,7 @@ test('createDrinkType creates new drink type with provided values', function ()
expect($drinkType->getDesiredStock())->toBe($desiredStock);
});
test('createDrinkType creates new drink type with default desired stock', function () {
test('createDrinkType creates new drink type with default desired stock', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$configService = $this->getContainer()->get(ConfigurationService::class);
@ -122,10 +123,10 @@ test('createDrinkType creates new drink type with default desired stock', functi
expect($drinkType)->toBeInstanceOf(DrinkType::class);
expect($drinkType->getName())->toBe($name);
expect($drinkType->getDescription())->toBe($description);
expect($drinkType->getDesiredStock())->toBe((int)$defaultDesiredStock);
expect($drinkType->getDesiredStock())->toBe((int) $defaultDesiredStock);
});
test('createDrinkType throws exception when drink type with same name exists', function () {
test('createDrinkType throws exception when drink type with same name exists', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$name = 'Duplicate Drink Type';
@ -138,7 +139,7 @@ test('createDrinkType throws exception when drink type with same name exists', f
->toThrow(InvalidArgumentException::class);
});
test('updateDrinkType updates drink type properties', function () {
test('updateDrinkType updates drink type properties', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -170,7 +171,7 @@ test('updateDrinkType updates drink type properties', function () {
expect($updatedDrinkType->getDesiredStock())->toBe($newDesiredStock);
});
test('updateDrinkType throws exception when updating to existing name', function () {
test('updateDrinkType throws exception when updating to existing name', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -190,7 +191,7 @@ test('updateDrinkType throws exception when updating to existing name', function
->toThrow(InvalidArgumentException::class);
});
test('updateDrinkType only updates provided properties', function () {
test('updateDrinkType only updates provided properties', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -220,7 +221,7 @@ test('updateDrinkType only updates provided properties', function () {
expect($updatedDrinkType->getDesiredStock())->toBe(5);
});
test('deleteDrinkType removes drink type', function () {
test('deleteDrinkType removes drink type', function (): void {
// Arrange
$drinkTypeService = $this->getContainer()->get(DrinkTypeService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);

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);

View file

@ -1,17 +1,17 @@
<?php
declare(strict_types=1);
use App\Entity\DrinkType;
use App\Entity\Order;
use App\Entity\OrderItem;
use App\Enum\OrderStatus;
use App\Repository\DrinkTypeRepository;
use App\Repository\OrderItemRepository;
use App\Repository\OrderRepository;
use App\Service\InventoryService;
use App\Service\OrderService;
use Doctrine\ORM\EntityManagerInterface;
test('getAllOrders returns all orders', function () {
test('getAllOrders returns all orders', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
@ -22,7 +22,7 @@ test('getAllOrders returns all orders', function () {
expect($orders)->toBeArray();
});
test('getOrderById returns correct order', function () {
test('getOrderById returns correct order', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -43,7 +43,7 @@ test('getOrderById returns correct order', function () {
expect($retrievedOrder->getId())->toBe($id);
});
test('getOrderById returns null for non-existent id', function () {
test('getOrderById returns null for non-existent id', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$nonExistentId = 9999;
@ -55,7 +55,7 @@ test('getOrderById returns null for non-existent id', function () {
expect($order)->toBeNull();
});
test('getOrdersByStatus returns orders with specific status', function () {
test('getOrdersByStatus returns orders with specific status', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -95,7 +95,7 @@ test('getOrdersByStatus returns orders with specific status', function () {
}
});
test('getActiveOrders returns orders with active statuses', function () {
test('getActiveOrders returns orders with active statuses', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -130,7 +130,7 @@ test('getActiveOrders returns orders with active statuses', function () {
}
});
test('getMostRecentActiveOrder returns most recent active order', function () {
test('getMostRecentActiveOrder returns most recent active order', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -158,7 +158,7 @@ test('getMostRecentActiveOrder returns most recent active order', function () {
expect($recentOrder->getId())->toBe($order2->getId());
});
test('hasActiveOrders returns true when active orders exist', function () {
test('hasActiveOrders returns true when active orders exist', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -176,7 +176,7 @@ test('hasActiveOrders returns true when active orders exist', function () {
expect($hasActiveOrders)->toBeTrue();
});
test('getOrdersByDateRange returns orders within date range', function () {
test('getOrdersByDateRange returns orders within date range', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -204,7 +204,7 @@ test('getOrdersByDateRange returns orders within date range', function () {
}
});
test('createOrder creates new order with items', function () {
test('createOrder creates new order with items', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -222,8 +222,14 @@ test('createOrder creates new order with items', function () {
$em->flush();
$items = [
['drinkTypeId' => $drinkType1->getId(), 'quantity' => 3],
['drinkTypeId' => $drinkType2->getId(), 'quantity' => 2],
[
'drinkTypeId' => $drinkType1->getId(),
'quantity' => 3,
],
[
'drinkTypeId' => $drinkType2->getId(),
'quantity' => 2,
],
];
// Act
@ -241,7 +247,7 @@ test('createOrder creates new order with items', function () {
expect($orderItems[1]->getQuantity())->toBe(2);
});
test('createOrderFromStockLevels creates order based on stock levels', function () {
test('createOrderFromStockLevels creates order based on stock levels', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$inventoryService = $this->getContainer()->get(InventoryService::class);
@ -295,7 +301,7 @@ test('createOrderFromStockLevels creates order based on stock levels', function
}
});
test('updateOrderStatus updates order status', function () {
test('updateOrderStatus updates order status', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -316,7 +322,7 @@ test('updateOrderStatus updates order status', function () {
// Verify the status was updated in the database
});
test('addOrderItem adds item to order', function () {
test('addOrderItem adds item to order', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -348,7 +354,7 @@ test('addOrderItem adds item to order', function () {
expect($order->getOrderItems()->contains($orderItem))->toBeTrue();
});
test('addOrderItem updates quantity if item already exists', function () {
test('addOrderItem updates quantity if item already exists', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -380,12 +386,12 @@ test('addOrderItem updates quantity if item already exists', function () {
// Verify the order still has only one item for this drink type
$matchingItems = $order->getOrderItems()->filter(
fn($item) => $item->getDrinkType()->getId() === $drinkType->getId()
fn($item): bool => $item->getDrinkType()->getId() === $drinkType->getId()
);
expect($matchingItems->count())->toBe(1);
});
test('removeOrderItem removes item from order', function () {
test('removeOrderItem removes item from order', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);
@ -414,12 +420,12 @@ test('removeOrderItem removes item from order', function () {
// Verify the item was removed from the database
$em->refresh($order);
$matchingItems = $order->getOrderItems()->filter(
fn($item) => $item->getDrinkType()->getId() === $drinkType->getId()
fn($item): bool => $item->getDrinkType()->getId() === $drinkType->getId()
);
expect($matchingItems->count())->toBe(0);
});
test('deleteOrder removes order and its items', function () {
test('deleteOrder removes order and its items', function (): void {
// Arrange
$orderService = $this->getContainer()->get(OrderService::class);
$em = $this->getContainer()->get(EntityManagerInterface::class);