fix: missing and wrong keys

This commit is contained in:
Francis Hilaire 2026-06-01 10:41:13 +02:00
parent 7dbc0ab30c
commit 1484d67c1f
No known key found for this signature in database
GPG key ID: 3392F830BF33D421

View file

@ -1077,7 +1077,7 @@ final readonly class ManagingOrdersContext implements Context
{ {
$orderItem = $this->sharedStorage->get('item'); $orderItem = $this->sharedStorage->get('item');
$quantityKey = $this->getNormalizedKey('quantity'); $quantityKey = $this->getNormalizedKey('quantity');
Assert::same($quantity, $orderItem['quantity']); Assert::same($quantity, $orderItem[$quantityKey]);
} }
/** /**
@ -1093,11 +1093,11 @@ final readonly class ManagingOrdersContext implements Context
AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT, AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT,
); );
$orderItemUnitsKey = $this->getNormalizedKey('orderItemUnits'); $orderItemUnitKey = $this->getNormalizedKey('orderItemUnit');
$unitsKey = $this->getNormalizedKey('units'); $unitsKey = $this->getNormalizedKey('units');
$amountKey = $this->getNormalizedKey('amount'); $amountKey = $this->getNormalizedKey('amount');
foreach ($adjustments as $adjustment) { foreach ($adjustments as $adjustment) {
if (in_array($adjustment[$orderItemUnitsKey], $orderItem[$unitsKey])) { if (in_array($adjustment[$orderItemUnitKey], $orderItem[$unitsKey])) {
Assert::same($this->getTotalAsInt($price), $adjustment[$amountKey]); Assert::same($this->getTotalAsInt($price), $adjustment[$amountKey]);
return; return;
@ -1118,11 +1118,11 @@ final readonly class ManagingOrdersContext implements Context
AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT, AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT,
); );
$orderItemUnitsKey = $this->getNormalizedKey('orderItemUnits'); $orderItemUnitKey = $this->getNormalizedKey('orderItemUnit');
$unitsKey = $this->getNormalizedKey('units'); $unitsKey = $this->getNormalizedKey('units');
$amountKey = $this->getNormalizedKey('amount'); $amountKey = $this->getNormalizedKey('amount');
foreach ($adjustments as $adjustment) { foreach ($adjustments as $adjustment) {
if (in_array($adjustment[$orderItemUnitsKey], $orderItem[$unitsKey])) { if (in_array($adjustment[$orderItemUnitKey], $orderItem[$unitsKey])) {
Assert::same($this->getTotalAsInt(trim($price, ' ~')), $adjustment[$amountKey]); Assert::same($this->getTotalAsInt(trim($price, ' ~')), $adjustment[$amountKey]);
return; return;
@ -1139,13 +1139,13 @@ final readonly class ManagingOrdersContext implements Context
$response = $this->getAdjustmentsResponseForOrder(true); $response = $this->getAdjustmentsResponseForOrder(true);
$typeKey = $this->getNormalizedKey('type'); $typeKey = $this->getNormalizedKey('type');
$orderItemUnitsKey = $this->getNormalizedKey('orderItemUnits'); $orderItemUnitKey = $this->getNormalizedKey('orderItemUnit');
$unitsKey = $this->getNormalizedKey('units'); $unitsKey = $this->getNormalizedKey('units');
$amountKey = $this->getNormalizedKey('amount'); $amountKey = $this->getNormalizedKey('amount');
$unitPromotionAdjustments = 0; $unitPromotionAdjustments = 0;
foreach ($this->responseChecker->getCollection($response) as $adjustment) { foreach ($this->responseChecker->getCollection($response) as $adjustment) {
if (in_array($adjustment[$typeKey], [AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT, AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT])) { if (in_array($adjustment[$typeKey], [AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT, AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT])) {
if (in_array($adjustment[$orderItemUnitsKey], $orderItem[$unitsKey])) { if (in_array($adjustment[$orderItemUnitKey], $orderItem[$unitsKey])) {
$unitPromotionAdjustments += $adjustment[$amountKey]; $unitPromotionAdjustments += $adjustment[$amountKey];
} }
} }