File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ class Shipping extends Form
45
45
46
46
/**
47
47
* Fields that are used in estimation shipping form.
48
+ * Indexes of this array should be numeric, they are used in compare() method.
48
49
*
49
50
* @var array
50
51
*/
@@ -91,6 +92,29 @@ public function selectShippingMethod(array $shipping)
91
92
}
92
93
}
93
94
95
+ /**
96
+ * Compare elements according to $this->estimationFields order
97
+ *
98
+ * @param $a
99
+ * @param $b
100
+ * @return int
101
+ */
102
+ public function compare ($ a , $ b )
103
+ {
104
+ $ a = array_search ($ a , $ this ->estimationFields );
105
+ $ b = array_search ($ b , $ this ->estimationFields );
106
+ switch (true ) {
107
+ case false !== $ a && false !== $ b :
108
+ return $ a - $ b ;
109
+ case false !== $ a :
110
+ return -1 ;
111
+ case false !== $ b :
112
+ return 1 ;
113
+ default :
114
+ return 0 ;
115
+ }
116
+ }
117
+
94
118
/**
95
119
* Fill shipping and tax form.
96
120
*
@@ -102,6 +126,8 @@ public function fillEstimateShippingAndTax(Address $address)
102
126
$ this ->openEstimateShippingAndTax ();
103
127
$ data = $ address ->getData ();
104
128
$ mapping = $ this ->dataMapping (array_intersect_key ($ data , array_flip ($ this ->estimationFields )));
129
+ // sort array according to $this->estimationFields element order
130
+ uksort ($ mapping , [$ this , 'compare ' ]);
105
131
106
132
// Test environment may become unstable when form fields are filled in a default manner.
107
133
// Imitating behavior closer to the real user.
You can’t perform that action at this time.
0 commit comments