File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -183,7 +183,7 @@ protected function getShippingMethodBlock()
183
183
*
184
184
* @return \Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals
185
185
*/
186
- protected function getTotalsBlock ()
186
+ public function getTotalsBlock ()
187
187
{
188
188
return $ this ->blockFactory ->create (
189
189
'Magento\Sales\Test\Block\Adminhtml\Order\Create\Totals ' ,
Original file line number Diff line number Diff line change 6
6
7
7
namespace Magento \Sales \Test \Block \Adminhtml \Order \Create ;
8
8
9
+ use Magento \Framework \DataObject ;
9
10
use Magento \Mtf \Block \Block ;
10
11
11
12
/**
@@ -22,11 +23,58 @@ class Totals extends Block
22
23
*/
23
24
protected $ submitOrder = '.order-totals-actions button ' ;
24
25
26
+ /**
27
+ * Order totals table
28
+ *
29
+ * @var string
30
+ */
31
+ protected $ totalsTable = '.data-table ' ;
32
+
25
33
/**
26
34
* Click 'Submit Order' button
27
35
*/
28
36
public function submitOrder ()
29
37
{
30
38
$ this ->_rootElement ->find ($ this ->submitOrder )->click ();
31
39
}
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
+ }
32
80
}
You can’t perform that action at this time.
0 commit comments