Skip to content

Commit e096031

Browse files
committed
MAGETWO-62624: Order total still displays when no related option is selected
1 parent 6fad45d commit e096031

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ protected function getShippingMethodBlock()
183183
*
184184
* @return \Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals
185185
*/
186-
protected function getTotalsBlock()
186+
public function getTotalsBlock()
187187
{
188188
return $this->blockFactory->create(
189189
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals',

dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create/Totals.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Sales\Test\Block\Adminhtml\Order\Create;
88

9+
use Magento\Framework\DataObject;
910
use Magento\Mtf\Block\Block;
1011

1112
/**
@@ -22,11 +23,58 @@ class Totals extends Block
2223
*/
2324
protected $submitOrder = '.order-totals-actions button';
2425

26+
/**
27+
* Order totals table
28+
*
29+
* @var string
30+
*/
31+
protected $totalsTable = '.data-table';
32+
2533
/**
2634
* Click 'Submit Order' button
2735
*/
2836
public function submitOrder()
2937
{
3038
$this->_rootElement->find($this->submitOrder)->click();
3139
}
40+
41+
/**
42+
* Return totals by labels
43+
*
44+
* @param $totals string[]
45+
* @return array
46+
*/
47+
public function getTotals($totals)
48+
{
49+
if (empty ($totals)) {
50+
return [];
51+
}
52+
53+
$totalsResult = [];
54+
55+
$totalsTable = $this->_rootElement->find($this->totalsTable);
56+
$rawTable = $totalsTable->getText();
57+
$existingTotals = explode(PHP_EOL, $rawTable);
58+
foreach ($totals as $total) {
59+
foreach ($existingTotals as $rowTotal) {
60+
if (strpos($rowTotal, $total) !== false) {
61+
$totalValue = trim(str_replace($total, '', $rowTotal));
62+
$totalsResult[$total] = $this->_escapeNumericValue($totalValue);
63+
}
64+
}
65+
}
66+
67+
return $totalsResult;
68+
}
69+
70+
/**
71+
* Escape numeric value
72+
*
73+
* @param string $value
74+
* @return mixed
75+
*/
76+
private function _escapeNumericValue($value)
77+
{
78+
return preg_replace("/[^-0-9\\.]/", "", $value);
79+
}
3280
}

0 commit comments

Comments
 (0)