Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc6d362

Browse files
authored
bug #10854 [Behat][Admin][Order] Fix scenarios for displaying promotions on master after upmerge (GSadee)
This PR was merged into the 1.6-dev branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | after #10846, associated with #10853 | License | MIT Commits ------- a14a599 [Behat][Admin][Order] Fix scenarios for displaying promotions on master after upmerge
2 parents 0094f34 + a14a599 commit cc6d362

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

features/order/managing_orders/seeing_order_discounts.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ Feature: Seeing discounts of an order
3333
And the customer chose "Free" shipping method to "United States" with "Cash on Delivery" payment
3434
When I view the summary of the order "#00000666"
3535
Then the order's items total should be "$29.00"
36-
And the order's promotion total should be "$0.00"
36+
And the order's promotion total should be "-$10.00"
37+
And the order's promotion discount should be "-$10.00" from "Holiday promotion" promotion
3738
And the order's total should be "$29.00"

src/Sylius/Behat/Page/Admin/Order/ShowPage.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,9 @@ public function hasShippingCharge(string $shippingCharge): bool
188188

189189
public function getOrderPromotionTotal(): string
190190
{
191-
/** @var NodeElement[] $rows */
192-
$rows = $this->getElement('table')->findAll('css', 'tbody tr');
191+
$promotionTotalElement = $this->getElement('promotion_total');
193192

194-
$orderPromotionTotal = 0;
195-
196-
foreach ($rows as $row) {
197-
$unitOrderPromotion = $row->find('css', 'td:nth-child(4)')->getText();
198-
$quantity = $row->find('css', 'td:nth-child(6)')->getText();
199-
$itemOrderPromotion = (float) trim(str_replace('-$', '', $unitOrderPromotion)) * $quantity;
200-
$orderPromotionTotal += (int) ($itemOrderPromotion * 100);
201-
}
202-
203-
return $this->getFormattedMoney($orderPromotionTotal > 0 ? -1 * $orderPromotionTotal : $orderPromotionTotal);
193+
return trim(str_replace('Promotion total:', '', $promotionTotalElement->getText()));
204194
}
205195

206196
public function hasPromotionDiscount(string $promotionName, string $promotionAmount): bool

0 commit comments

Comments
 (0)