Skip to content

Commit b2bb4f7

Browse files
author
Stanislav Idolov
committed
MAGETWO-58334: [Github] Free shipping is not applied if cart price rule match #6584
-- functional test
1 parent 60e8c84 commit b2bb4f7

File tree

5 files changed

+155
-0
lines changed

5 files changed

+155
-0
lines changed

dev/tests/functional/tests/app/Magento/Catalog/Test/Repository/CatalogProductSimple.xml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,5 +1233,35 @@
12331233
<field name="url_key" xsi:type="string">overnight-duffle</field>
12341234
</dataset>
12351235

1236+
<dataset name="simple_with_weight_10_for_salesrule">
1237+
<field name="attribute_set_id" xsi:type="array">
1238+
<item name="dataset" xsi:type="string">default</item>
1239+
</field>
1240+
<field name="name" xsi:type="string">Simple Product %isolation%</field>
1241+
<field name="sku" xsi:type="string">sku_simple_product_%isolation%</field>
1242+
<field name="product_has_weight" xsi:type="string">This item has weight</field>
1243+
<field name="weight" xsi:type="string">10</field>
1244+
<field name="quantity_and_stock_status" xsi:type="array">
1245+
<item name="qty" xsi:type="string">25</item>
1246+
<item name="is_in_stock" xsi:type="string">In Stock</item>
1247+
</field>
1248+
<field name="price" xsi:type="array">
1249+
<item name="value" xsi:type="string">560</item>
1250+
</field>
1251+
<field name="tax_class_id" xsi:type="array">
1252+
<item name="dataset" xsi:type="string">taxable_goods</item>
1253+
</field>
1254+
<field name="website_ids" xsi:type="array">
1255+
<item name="0" xsi:type="array">
1256+
<item name="dataset" xsi:type="string">default</item>
1257+
</item>
1258+
</field>
1259+
<field name="visibility" xsi:type="string">Catalog, Search</field>
1260+
<field name="url_key" xsi:type="string">simple-product-%isolation%</field>
1261+
<field name="checkout_data" xsi:type="array">
1262+
<item name="dataset" xsi:type="string">simple_order_default</item>
1263+
</field>
1264+
</dataset>
1265+
12361266
</repository>
12371267
</config>

dev/tests/functional/tests/app/Magento/SalesRule/Test/Handler/SalesRule/Curl.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class Curl extends Conditions implements SalesRuleInterface
7070
'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class,
7171
'attribute' => 'postcode',
7272
],
73+
'Total Weight' => [
74+
'type' => \Magento\SalesRule\Model\Rule\Condition\Address::class,
75+
'attribute' => 'weight',
76+
],
7377
'Category' => [
7478
'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class,
7579
'attribute' => 'category_ids',

dev/tests/functional/tests/app/Magento/SalesRule/Test/Repository/SalesRule.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,5 +279,24 @@
279279
<field name="stop_rules_processing" xsi:type="string">No</field>
280280
<field name="simple_free_shipping" xsi:type="string">No</field>
281281
</dataset>
282+
<dataset name="rule_with_freeshipping_by_weight">
283+
<field name="name" xsi:type="string">Cart price rule with free shipping by weight</field>
284+
<field name="is_active" xsi:type="string">Yes</field>
285+
<field name="website_ids" xsi:type="array">
286+
<item name="0" xsi:type="string">Main Website</item>
287+
</field>
288+
<field name="customer_group_ids" xsi:type="array">
289+
<item name="0" xsi:type="string">NOT LOGGED IN</item>
290+
</field>
291+
<field name="coupon_type" xsi:type="string">No Coupon</field>
292+
<field name="sort_order" xsi:type="string">1</field>
293+
<field name="is_rss" xsi:type="string">Yes</field>
294+
<field name="conditions_serialized" xsi:type="string">[Total Weight|is|1]</field>
295+
<field name="simple_action" xsi:type="string">Percent of product price discount</field>
296+
<field name="discount_amount" xsi:type="string">0</field>
297+
<field name="apply_to_shipping" xsi:type="string">No</field>
298+
<field name="stop_rules_processing" xsi:type="string">No</field>
299+
<field name="simple_free_shipping" xsi:type="string">For matching items only</field>
300+
</dataset>
282301
</repository>
283302
</config>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\SalesRule\Test\TestCase;
8+
9+
/**
10+
* Precondition:
11+
* 1. Cart Price Rule was created.
12+
*
13+
* Steps:
14+
* 1. Go to storefront
15+
* 2. Add product to shopping cart
16+
* 3. Go to shopping cart page
17+
* 4. Perform asserts.
18+
*
19+
* @group Shopping_Cart_Price_Rules
20+
* @ZephyrId MAGETWO-59665
21+
*/
22+
class ShoppingCartWithFreeShippingTest extends \Magento\Mtf\TestCase\Injectable
23+
{
24+
/**
25+
* @var \Magento\Mtf\TestStep\TestStepFactory
26+
*/
27+
private $testStepFactory;
28+
29+
/**
30+
* Inject data
31+
*
32+
* @param \Magento\Mtf\TestStep\TestStepFactory $testStepFactory
33+
* @return void
34+
*/
35+
public function __inject(
36+
\Magento\Mtf\TestStep\TestStepFactory $testStepFactory
37+
) {
38+
$this->testStepFactory = $testStepFactory;
39+
}
40+
41+
/**
42+
* Test sales rule with free shipping applied by product weight
43+
*
44+
* @param \Magento\SalesRule\Test\Fixture\SalesRule $salesRule
45+
* @param \Magento\Catalog\Test\Fixture\CatalogProductSimple $product
46+
* @param \Magento\Checkout\Test\Fixture\Cart $cart
47+
* @return void
48+
*/
49+
public function testRuleWithFreeShippingByWeight(
50+
\Magento\SalesRule\Test\Fixture\SalesRule $salesRule,
51+
\Magento\Catalog\Test\Fixture\CatalogProductSimple $product,
52+
\Magento\Checkout\Test\Fixture\Cart $cart
53+
) {
54+
$salesRule->persist();
55+
$product->persist();
56+
57+
$this->testStepFactory->create(
58+
\Magento\Checkout\Test\TestStep\AddProductsToTheCartStep::class,
59+
['products' => [$product]]
60+
)->run();
61+
62+
$this->testStepFactory->create(
63+
\Magento\Checkout\Test\TestStep\EstimateShippingAndTaxStep::class,
64+
['products' => [$product], 'cart' => $cart]
65+
)->run();
66+
}
67+
68+
/**
69+
* Clear data after test.
70+
*
71+
* @return void
72+
*/
73+
public function tearDown()
74+
{
75+
$this->testStepFactory->create(\Magento\SalesRule\Test\TestStep\DeleteAllSalesRuleStep::class)->run();
76+
}
77+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. 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\SalesRule\Test\TestCase\ShoppingCartWithFreeShippingTest" summary="Shopping Cart With Freeshipping" ticketId="MAGETWO-59665">
10+
<variation name="ShoppingCartWithFreeShippingTestVariation1">
11+
<data name="salesRule/dataset" xsi:type="string">rule_with_freeshipping_by_weight</data>
12+
<data name="product/dataset" xsi:type="string">default</data>
13+
<data name="cart/data/subtotal" xsi:type="string">560.00</data>
14+
<data name="cart/data/shipping_amount" xsi:type="string">0.00</data>
15+
<data name="cart/data/grand_total" xsi:type="string">560.00</data>
16+
</variation>
17+
<variation name="ShoppingCartWithFreeShippingTestVariation2">
18+
<data name="salesRule/dataset" xsi:type="string">rule_with_freeshipping_by_weight</data>
19+
<data name="product/dataset" xsi:type="string">simple_with_weight_10_for_salesrule</data>
20+
<data name="cart/data/subtotal" xsi:type="string">560.00</data>
21+
<data name="cart/data/shipping_amount" xsi:type="string">5.00</data>
22+
<data name="cart/data/grand_total" xsi:type="string">565.00</data>
23+
</variation>
24+
</testCase>
25+
</config>

0 commit comments

Comments
 (0)