Skip to content

Commit 53e419c

Browse files
committed
MAGETWO-62624: Order total still displays when no related option is selected
1 parent 3615477 commit 53e419c

File tree

1 file changed

+41
-17
lines changed
  • dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Create

1 file changed

+41
-17
lines changed

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

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,51 @@
77
namespace Magento\Sales\Test\Block\Adminhtml\Order\Create;
88

99
use Magento\Mtf\Block\Block;
10+
use Magento\Mtf\Client\Locator;
1011

1112
/**
12-
* Class Totals
13-
* Adminhtml sales order create totals block
14-
*
13+
* Adminhtml sales order create totals block.
1514
*/
1615
class Totals extends Block
1716
{
1817
/**
19-
* 'Submit Order' button
18+
* 'Submit Order' button.
2019
*
2120
* @var string
2221
*/
2322
protected $submitOrder = '.order-totals-actions button';
2423

2524
/**
26-
* Order totals table
25+
* Order totals table.
2726
*
2827
* @var string
2928
*/
3029
protected $totalsTable = '.data-table';
3130

3231
/**
33-
* Click 'Submit Order' button
32+
* Total row label selector.
33+
*
34+
* @var string
35+
*/
36+
protected $totalLabelLocator = './/tr[normalize-space(td)="%s"]';
37+
38+
/**
39+
* Total value selector.
40+
*
41+
* @var string
42+
*/
43+
protected $totalValueLocator = './/td/span[contains(@class,"price")]';
44+
45+
/**
46+
* Click 'Submit Order' button.
3447
*/
3548
public function submitOrder()
3649
{
3750
$this->_rootElement->find($this->submitOrder)->click();
3851
}
3952

4053
/**
41-
* Return totals by labels
54+
* Return totals by labels.
4255
*
4356
* @param $totals string[]
4457
* @return array
@@ -50,29 +63,40 @@ public function getTotals($totals)
5063
}
5164

5265
$totalsResult = [];
53-
5466
$totalsTable = $this->_rootElement->find($this->totalsTable);
55-
$rawTable = $totalsTable->getText();
56-
$existingTotals = explode(PHP_EOL, $rawTable);
67+
5768
foreach ($totals as $total) {
58-
foreach ($existingTotals as $rowTotal) {
59-
if (strpos($rowTotal, $total) !== false) {
60-
$totalValue = trim(str_replace($total, '', $rowTotal));
61-
$totalsResult[$total] = $this->_escapeNumericValue($totalValue);
62-
}
69+
70+
$totalRow = $totalsTable->find(sprintf($this->totalLabelLocator, $total), Locator::SELECTOR_XPATH);
71+
if ($totalRow->isVisible()) {
72+
$totalValue = $totalRow->find($this->totalValueLocator, Locator::SELECTOR_XPATH);
73+
$totalsResult[$total] = $this->escapeNumericValue($totalValue->getText());
6374
}
6475
}
6576

6677
return $totalsResult;
6778
}
6879

6980
/**
70-
* Escape numeric value
81+
* Return total presence by label.
82+
*
83+
* @param string $total
84+
* @return bool
85+
*/
86+
public function isTotalPresent($total)
87+
{
88+
$totalsTable = $this->_rootElement->find($this->totalsTable);
89+
$totalRow = $totalsTable->find(sprintf($this->totalLabelLocator, $total), Locator::SELECTOR_XPATH);
90+
return $totalRow->isVisible();
91+
}
92+
93+
/**
94+
* Escape numeric value.
7195
*
7296
* @param string $value
7397
* @return mixed
7498
*/
75-
private function _escapeNumericValue($value)
99+
private function escapeNumericValue($value)
76100
{
77101
return preg_replace("/[^-0-9\\.]/", "", $value);
78102
}

0 commit comments

Comments
 (0)