Skip to content

Commit e21abf9

Browse files
committed
MAGETWO-57880: [GITHUB] Cancel an order of bundle product #5194
1 parent e9255f4 commit e21abf9

File tree

8 files changed

+162
-3
lines changed

8 files changed

+162
-3
lines changed

dev/tests/functional/tests/app/Magento/Bundle/Test/Fixture/Cart/Item.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public function getData($key = null)
4646
$optionData = [
4747
'title' => $checkoutOption['title'],
4848
'value' => "{$qty} x {$value} {$price}",
49+
'sku' => "{$qty} x {$value}"
4950
];
5051

5152
$checkoutBundleOptions[$checkoutOptionKey] = $optionData;

dev/tests/functional/tests/app/Magento/Bundle/Test/Repository/BundleProduct.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,5 +411,43 @@
411411
<item name="dataset" xsi:type="string">bundle_low_stock_fixed</item>
412412
</field>
413413
</dataset>
414+
415+
<dataset name="bundle_dynamic_product_shipment_together">
416+
<field name="name" xsi:type="string">Bundle dynamic product %isolation%</field>
417+
<field name="sku" xsi:type="string">sku_bundle_dynamic_product_%isolation%</field>
418+
<field name="sku_type" xsi:type="string">Yes</field>
419+
<field name="price_type" xsi:type="string">Yes</field>
420+
<field name="price" xsi:type="array">
421+
<item name="dataset" xsi:type="string">default_dynamic</item>
422+
</field>
423+
<field name="quantity_and_stock_status" xsi:type="array">
424+
<item name="is_in_stock" xsi:type="string">In Stock</item>
425+
</field>
426+
<field name="weight_type" xsi:type="string">Yes</field>
427+
<field name="shipment_type" xsi:type="string">Together</field>
428+
<field name="tax_class_id" xsi:type="array">
429+
<item name="dataset" xsi:type="string">taxable_goods</item>
430+
</field>
431+
<field name="website_ids" xsi:type="array">
432+
<item name="0" xsi:type="array">
433+
<item name="dataset" xsi:type="string">default</item>
434+
</item>
435+
</field>
436+
<field name="stock_data" xsi:type="array">
437+
<item name="manage_stock" xsi:type="string">Yes</item>
438+
<item name="use_config_enable_qty_increments" xsi:type="string">Yes</item>
439+
<item name="use_config_qty_increments" xsi:type="string">Yes</item>
440+
<item name="is_in_stock" xsi:type="string">In Stock</item>
441+
</field>
442+
<field name="url_key" xsi:type="string">bundle-dynamic-product-%isolation%</field>
443+
<field name="visibility" xsi:type="string">Catalog, Search</field>
444+
<field name="bundle_selections" xsi:type="array">
445+
<item name="dataset" xsi:type="string">default_dynamic</item>
446+
</field>
447+
<field name="attribute_set_id" xsi:type="string">Default</field>
448+
<field name="checkout_data" xsi:type="array">
449+
<item name="dataset" xsi:type="string">bundle_default_dynamic</item>
450+
</field>
451+
</dataset>
414452
</repository>
415453
</config>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Bundle\Test\TestCase;
8+
9+
use Magento\Mtf\TestCase\Scenario;
10+
11+
/**
12+
* Preconditions:
13+
* 1. Enable payment method: "Transfer/Cash on Delivery/Purchase Order/Zero Subtotal Checkout".
14+
* 2. Enable shipping method one of "Flat Rate.
15+
* 3. Create order.
16+
*
17+
* Steps:
18+
* 1. Login to backend.
19+
* 2. Sales > Orders.
20+
* 3. Open the created order.
21+
* 4. Create partial invoice
22+
* 4. Do cancel Order.
23+
* 5. Perform all assetions.
24+
*
25+
* @group Order_Management
26+
* @ZephyrId MAGETWO-67787
27+
*/
28+
class CancelPartiallyInvoicedOrderTest extends Scenario
29+
{
30+
/**
31+
* Runs test for invoice creation for order placed with offline payment method.
32+
*
33+
* @return void
34+
*/
35+
public function test()
36+
{
37+
$this->executeScenario();
38+
}
39+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Bundle\Test\TestCase\CancelPartiallyInvoicedOrderTest" summary="Cancel for order that was partially invoiced with Bundle product type" ticketId="MAGETWO-67787">
10+
<variation name="CancelPartiallyInvoicedOrderWithBundleProductTest">
11+
<data name="order/dataset" xsi:type="string">default</data>
12+
<data name="order/data/entity_id/products" xsi:type="string">bundleProduct::bundle_dynamic_product_shipment_together</data>
13+
<data name="order/data/total_qty_ordered/0" xsi:type="string">-</data>
14+
<data name="order/data/payment_auth_expiration/method" xsi:type="string">cashondelivery</data>
15+
<data name="order/data/invoice" xsi:type="array">
16+
<item name="0" xsi:type="array">
17+
<item name="items_data" xsi:type="array">
18+
<item name="0" xsi:type="array">
19+
<item name="qty" xsi:type="string">1</item>
20+
</item>
21+
</item>
22+
</item>
23+
</data>
24+
<data name="configData" xsi:type="string">cashondelivery</data>
25+
<data name="status" xsi:type="string">Processing</data>
26+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderCancelSuccessMessage" />
27+
<constraint name="Magento\Sales\Test\Constraint\AssertOrderInOrdersGrid" />
28+
</variation>
29+
</testCase>
30+
</config>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Bundle\Test\TestStep;
8+
9+
use Magento\Mtf\TestStep\TestStepInterface;
10+
11+
/**
12+
* Create invoice from order on backend.
13+
*/
14+
class CreatePartialInvoiceStep extends \Magento\Sales\Test\TestStep\CreateInvoiceStep implements TestStepInterface
15+
{
16+
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
protected function getItems()
21+
{
22+
$items = parent::getItems();
23+
return $items[0]->getData()['options'];
24+
}
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/TestCase/etc/testcase.xsd">
9+
<scenario name="CancelPartiallyInvoicedOrderTest" firstStep="setupConfiguration">
10+
<step name="setupConfiguration" module="Magento_Config" next="createOrder" />
11+
<step name="createOrder" module="Magento_Sales" next="createPartialInvoice" />
12+
<step name="createPartialInvoice" module="Magento_Bundle" next="cancelOrder"/>
13+
<step name="cancelOrder" module="Magento_Sales" />
14+
</scenario>
15+
</config>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public function fillProductData(array $data, $products = null)
6969
$data = $this->prepareData($data);
7070
if (isset($data['items_data']) && $products !== null) {
7171
foreach ($data['items_data'] as $key => $item) {
72-
$productSku = $products[$key]->getData()['sku'];
72+
73+
$productSku = is_array($products[$key]) ? $products[$key]['sku'] : $products[$key]->getData()['sku'];
7374
$this->getItemsBlock()->getItemProductBlock($productSku)->fillProduct($item);
7475
}
7576
}

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ public function run()
125125
foreach ($invoicesData as $invoiceData) {
126126
$this->salesOrderView->getPageActions()->invoice();
127127

128-
$items = $this->cart->getItems();
128+
$items = $this->getItems();
129129
$this->orderInvoiceNew->getFormBlock()->fillProductData($invoiceData, $items);
130-
if ($this->compare($items, $invoiceData)) {
130+
if ($this->compare($this->cart->getItems(), $invoiceData)) {
131131
$this->orderInvoiceNew->getFormBlock()->updateQty();
132132
}
133133

@@ -166,4 +166,14 @@ protected function getShipmentIds()
166166
$this->salesOrderView->getOrderForm()->openTab('shipments');
167167
return $this->salesOrderView->getOrderForm()->getTab('shipments')->getGridBlock()->getIds();
168168
}
169+
170+
/**
171+
* Get cart items
172+
*
173+
* @return mixed
174+
*/
175+
protected function getItems()
176+
{
177+
return $this->cart->getItems();
178+
}
169179
}

0 commit comments

Comments
 (0)