File tree Expand file tree Collapse file tree 4 files changed +55
-3
lines changed
dev/tests/functional/tests/app/Magento/Sales/Test/TestStep Expand file tree Collapse file tree 4 files changed +55
-3
lines changed Original file line number Diff line number Diff line change 12
12
use Magento \Sales \Test \Page \Adminhtml \OrderIndex ;
13
13
use Magento \Sales \Test \Page \Adminhtml \SalesOrderView ;
14
14
use Magento \Mtf \TestStep \TestStepInterface ;
15
+ use Magento \Sales \Test \TestStep \Utils \CompareQtyTrait ;
15
16
16
17
/**
17
18
* Create credit memo from order on backend.
18
19
*/
19
20
class CreateCreditMemoStep implements TestStepInterface
20
21
{
22
+ use CompareQtyTrait;
23
+
21
24
/**
22
25
* Orders Page.
23
26
*
@@ -89,7 +92,7 @@ public function run()
89
92
90
93
$ items = $ this ->cart ->getItems ();
91
94
$ this ->orderCreditMemoNew ->getFormBlock ()->fillProductData ($ refundData , $ items );
92
- if (! empty ( $ refundData ) && count ( $ refundData ) !== count ( $ items )) {
95
+ if ($ this -> compare ( $ items , $ refundData )) {
93
96
$ this ->orderCreditMemoNew ->getFormBlock ()->updateQty ();
94
97
}
95
98
Original file line number Diff line number Diff line change 7
7
namespace Magento \Sales \Test \TestStep ;
8
8
9
9
use Magento \Checkout \Test \Fixture \Cart ;
10
+ use Magento \Mtf \Fixture \FixtureInterface ;
10
11
use Magento \Sales \Test \Fixture \OrderInjectable ;
11
12
use Magento \Sales \Test \Page \Adminhtml \OrderIndex ;
12
13
use Magento \Sales \Test \Page \Adminhtml \OrderInvoiceNew ;
13
14
use Magento \Sales \Test \Page \Adminhtml \OrderInvoiceView ;
14
15
use Magento \Sales \Test \Page \Adminhtml \SalesOrderView ;
16
+ use Magento \Sales \Test \TestStep \Utils \CompareQtyTrait ;
15
17
use Magento \Shipping \Test \Page \Adminhtml \OrderShipmentView ;
16
18
use Magento \Mtf \TestStep \TestStepInterface ;
17
19
20
22
*/
21
23
class CreateInvoiceStep implements TestStepInterface
22
24
{
25
+ use CompareQtyTrait;
26
+
23
27
/**
24
28
* Orders Page.
25
29
*
@@ -124,7 +128,7 @@ public function run()
124
128
125
129
$ items = $ this ->cart ->getItems ();
126
130
$ this ->orderInvoiceNew ->getFormBlock ()->fillProductData ($ invoiceData , $ items );
127
- if (! empty ( $ invoiceData ) && count ( $ invoiceData ) !== count ( $ items )) {
131
+ if ($ this -> compare ( $ items , $ invoiceData )) {
128
132
$ this ->orderInvoiceNew ->getFormBlock ()->updateQty ();
129
133
}
130
134
Original file line number Diff line number Diff line change 13
13
use Magento \Sales \Test \Page \Adminhtml \OrderIndex ;
14
14
use Magento \Sales \Test \Page \Adminhtml \OrderInvoiceView ;
15
15
use Magento \Sales \Test \Page \Adminhtml \SalesOrderView ;
16
+ use Magento \Sales \Test \TestStep \Utils \CompareQtyTrait ;
16
17
17
18
/**
18
19
* Create credit memo for order placed using online payment methods.
19
20
*/
20
21
class CreateOnlineCreditMemoStep implements TestStepInterface
21
22
{
23
+ use CompareQtyTrait;
24
+
22
25
/**
23
26
* Orders Page.
24
27
*
@@ -104,7 +107,7 @@ public function run()
104
107
105
108
$ items = $ this ->cart ->getItems ();
106
109
$ this ->orderCreditMemoNew ->getFormBlock ()->fillProductData ($ refundData , $ items );
107
- if (! empty ( $ refundData ) && count ( $ refundData ) !== count ( $ items )) {
110
+ if ($ this -> compare ( $ items , $ refundData )) {
108
111
$ this ->orderCreditMemoNew ->getFormBlock ()->updateQty ();
109
112
}
110
113
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © 2013-2017 Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ namespace Magento \Sales \Test \TestStep \Utils ;
8
+
9
+ use Magento \Mtf \Fixture \FixtureInterface ;
10
+
11
+ /**
12
+ * Compare qty in current order with qty in the entity form.
13
+ */
14
+ trait CompareQtyTrait
15
+ {
16
+ /**
17
+ * Compare items.
18
+ *
19
+ * @param FixtureInterface[] $products
20
+ * @param array $data
21
+ * @return bool
22
+ */
23
+ protected function compare (array $ products , array $ data )
24
+ {
25
+ if (empty ($ data ['items_data ' ])) {
26
+ return false ;
27
+ }
28
+
29
+ $ count = 0 ;
30
+ foreach ($ data ['items_data ' ] as $ key => $ item ) {
31
+ if (!isset ($ products [$ key ])) {
32
+ continue ;
33
+ }
34
+
35
+ if ($ products [$ key ]->getData ('qty ' ) !== $ item ['qty ' ]) {
36
+ ++$ count ;
37
+ }
38
+ }
39
+
40
+ return $ count !== 0 ;
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments