Skip to content

Commit 5f29c29

Browse files
committed
MTA-4096: Ignore functional test failures caused by Magento issues
- unified the comparison algorithm
1 parent 533e208 commit 5f29c29

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
1313
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
1414
use Magento\Mtf\TestStep\TestStepInterface;
15+
use Magento\Sales\Test\TestStep\Utils\CompareQtyTrait;
1516

1617
/**
1718
* Create credit memo from order on backend.
1819
*/
1920
class CreateCreditMemoStep implements TestStepInterface
2021
{
22+
use CompareQtyTrait;
23+
2124
/**
2225
* Orders Page.
2326
*
@@ -89,7 +92,7 @@ public function run()
8992

9093
$items = $this->cart->getItems();
9194
$this->orderCreditMemoNew->getFormBlock()->fillProductData($refundData, $items);
92-
if (!empty($refundData) && count($refundData) !== count($items)) {
95+
if ($this->compare($items, $refundData)) {
9396
$this->orderCreditMemoNew->getFormBlock()->updateQty();
9497
}
9598

dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateInvoiceStep.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
namespace Magento\Sales\Test\TestStep;
88

99
use Magento\Checkout\Test\Fixture\Cart;
10+
use Magento\Mtf\Fixture\FixtureInterface;
1011
use Magento\Sales\Test\Fixture\OrderInjectable;
1112
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
1213
use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceNew;
1314
use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceView;
1415
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
16+
use Magento\Sales\Test\TestStep\Utils\CompareQtyTrait;
1517
use Magento\Shipping\Test\Page\Adminhtml\OrderShipmentView;
1618
use Magento\Mtf\TestStep\TestStepInterface;
1719

@@ -20,6 +22,8 @@
2022
*/
2123
class CreateInvoiceStep implements TestStepInterface
2224
{
25+
use CompareQtyTrait;
26+
2327
/**
2428
* Orders Page.
2529
*
@@ -124,7 +128,7 @@ public function run()
124128

125129
$items = $this->cart->getItems();
126130
$this->orderInvoiceNew->getFormBlock()->fillProductData($invoiceData, $items);
127-
if (!empty($invoiceData) && count($invoiceData) !== count($items)) {
131+
if ($this->compare($items, $invoiceData)) {
128132
$this->orderInvoiceNew->getFormBlock()->updateQty();
129133
}
130134

dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateOnlineCreditMemoStep.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
1414
use Magento\Sales\Test\Page\Adminhtml\OrderInvoiceView;
1515
use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
16+
use Magento\Sales\Test\TestStep\Utils\CompareQtyTrait;
1617

1718
/**
1819
* Create credit memo for order placed using online payment methods.
1920
*/
2021
class CreateOnlineCreditMemoStep implements TestStepInterface
2122
{
23+
use CompareQtyTrait;
24+
2225
/**
2326
* Orders Page.
2427
*
@@ -104,7 +107,7 @@ public function run()
104107

105108
$items = $this->cart->getItems();
106109
$this->orderCreditMemoNew->getFormBlock()->fillProductData($refundData, $items);
107-
if (!empty($refundData) && count($refundData) !== count($items)) {
110+
if ($this->compare($items, $refundData)) {
108111
$this->orderCreditMemoNew->getFormBlock()->updateQty();
109112
}
110113

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
}

0 commit comments

Comments
 (0)