Skip to content

Commit 07f9f16

Browse files
committed
Merge pull request #230 from magento-firedrakes/MAGETWO-35629
[Firedrakes] Bug fixes
2 parents 927e8e2 + 98c6cda commit 07f9f16

File tree

28 files changed

+2784
-573
lines changed

28 files changed

+2784
-573
lines changed

app/code/Magento/Quote/Model/Quote.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
* sales_quote_delete_after
2828
*
2929
* @method Quote setStoreId(int $value)
30-
* @method Quote setIsVirtual(int $value)
3130
* @method int getIsMultiShipping()
3231
* @method Quote setIsMultiShipping(int $value)
3332
* @method float getStoreToBaseRate()
@@ -556,6 +555,14 @@ public function setIsActive($isActive)
556555
return $this->setData(self::KEY_IS_ACTIVE, $isActive);
557556
}
558557

558+
/**
559+
* {@inheritdoc}
560+
*/
561+
public function setIsVirtual($isVirtual)
562+
{
563+
return $this->setData(self::KEY_IS_VIRTUAL, $isVirtual);
564+
}
565+
559566
/**
560567
* {@inheritdoc}
561568
*/
@@ -772,6 +779,9 @@ public function beforeSave()
772779
$this->setCustomerId($this->_customer->getId());
773780
}
774781

782+
//mark quote if it has virtual products only
783+
$this->setIsVirtual($this->getIsVirtual());
784+
775785
parent::beforeSave();
776786
}
777787

app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Magento\Quote\Model\Quote\Address;
1212
use Magento\Store\Model\ScopeInterface;
13+
use Magento\Quote\Api\Data\CartInterface;
1314
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1415

1516
/**
@@ -1040,4 +1041,94 @@ public function testAddItem()
10401041

10411042
$this->quote->addItem($item);
10421043
}
1044+
1045+
/**
1046+
* @param array $productTypes
1047+
* @param int $expected
1048+
* @dataProvider dataProviderForTestBeforeSaveIsVirtualQuote
1049+
*/
1050+
public function testBeforeSaveIsVirtualQuote(array $productTypes, $expected)
1051+
{
1052+
$storeId = 1;
1053+
$currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency')
1054+
->disableOriginalConstructor()
1055+
->getMock();
1056+
$currencyMock->expects($this->any())
1057+
->method('getCode')
1058+
->will($this->returnValue('test_code'));
1059+
$currencyMock->expects($this->any())
1060+
->method('getRate')
1061+
->will($this->returnValue('test_rate'));
1062+
$storeMock = $this->getMockBuilder('Magento\Store\Model\Store')
1063+
->disableOriginalConstructor()
1064+
->getMock();
1065+
$storeMock->expects($this->once())
1066+
->method('getBaseCurrency')
1067+
->will($this->returnValue($currencyMock));
1068+
$storeMock->expects($this->once())
1069+
->method('getCurrentCurrency')
1070+
->will($this->returnValue($currencyMock));
1071+
1072+
$this->storeManagerMock->expects($this->any())
1073+
->method('getStore')
1074+
->with($storeId)
1075+
->will($this->returnValue($storeMock));
1076+
$this->quote->setStoreId($storeId);
1077+
1078+
$collectionMock = $this->getMock(
1079+
'Magento\Quote\Model\Resource\Quote\Item\Collection',
1080+
[],
1081+
[],
1082+
'',
1083+
false
1084+
);
1085+
$items = [];
1086+
foreach ($productTypes as $type) {
1087+
$productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);;
1088+
$productMock->expects($this->any())->method('getIsVirtual')->willReturn($type);
1089+
1090+
$itemMock = $this->getMock(
1091+
'Magento\Quote\Model\Quote\Item',
1092+
['isDeleted', 'getParentItemId', 'getProduct'],
1093+
[],
1094+
'',
1095+
false
1096+
);
1097+
$itemMock->expects($this->any())
1098+
->method('isDeleted')
1099+
->willReturn(false);
1100+
$itemMock->expects($this->any())
1101+
->method('getParentItemId')
1102+
->willReturn(false);
1103+
$itemMock->expects($this->any())
1104+
->method('getProduct')
1105+
->willReturn($productMock);
1106+
$items[] = $itemMock;
1107+
}
1108+
$iterator = new \ArrayIterator($items);
1109+
$collectionMock->expects($this->any())
1110+
->method('getIterator')
1111+
->will($this->returnValue($iterator));
1112+
$this->quoteItemCollectionFactoryMock->expects($this->once())
1113+
->method('create')
1114+
->will($this->returnValue($collectionMock));
1115+
1116+
$this->quote->beforeSave();
1117+
$this->assertEquals($expected, $this->quote->getDataByKey(CartInterface::KEY_IS_VIRTUAL));
1118+
}
1119+
1120+
1121+
/**
1122+
* @return array
1123+
*/
1124+
public function dataProviderForTestBeforeSaveIsVirtualQuote()
1125+
{
1126+
return [
1127+
[[true], 1],
1128+
[[true, true], 1],
1129+
[[false], 0],
1130+
[[true, false], 0],
1131+
[[false, false], 0]
1132+
];
1133+
}
10431134
}

dev/tests/functional/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"require": {
3-
"magento/mtf": "1.0.0-rc21",
3+
"magento/mtf": "1.0.0-rc22",
44
"php": "~5.5.0|~5.6.0",
55
"phpunit/phpunit": "4.1.0",
66
"phpunit/phpunit-selenium": ">=1.2",

dev/tests/functional/credentials.xml.dist

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,38 @@
77
-->
88
<replace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="./vendor/magento/mtf/Magento/Mtf/Fixture/InjectableFixture/etc/replace.xsd">
10+
<field path="carriers/fedex/account" value="" />
11+
<field path="carriers/fedex/meter_number" value="" />
12+
<field path="carriers/fedex/key" value="" />
13+
<field path="carriers/fedex/password" value="" />
1014

11-
<field path="section/carriers_dhl_id/value" value="" />
12-
<field path="section/carriers_dhl_password/value" value="" />
13-
<field path="section/carriers_dhl_account/value" value="" />
15+
<field path="payment/authorizenet/login" value="" />
16+
<field path="payment/authorizenet/trans_key" value="" />
1417

15-
<field path="section/carriers_fedex_account/value" value="" />
16-
<field path="section/carriers_fedex_meter_number/value" value="" />
17-
<field path="section/carriers_fedex_key/value" value="" />
18-
<field path="section/carriers_fedex_password/value" value="" />
18+
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/business_account" value="" />
19+
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_username" value="" />
20+
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_password" value="" />
21+
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_signature" value="" />
1922

20-
<field path="section/carriers_ups_password/value" value="" />
21-
<field path="section/carriers_ups_username/value" value="" />
22-
<field path="section/carriers_ups_access_license_number/value" value="" />
23-
<field path="section/carriers_ups_shipper_number/value" value="" />
23+
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/business_account" value="" />
24+
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/partner" value="" />
25+
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/user" value="" />
26+
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/pwd" value="" />
27+
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/vendor" value="" />
2428

25-
<field path="section/carriers_usps_userid/value" value="" />
26-
<field path="section/carriers_usps_password/value" value="" />
29+
<field path="carriers/ups/password" value="" />
30+
<field path="carriers/ups/username" value="" />
31+
<field path="carriers/ups/access_license_number" value="" />
32+
<field path="carriers/ups/shipper_number" value="" />
2733

28-
<field path="section/payment_authorizenet_login/value" value="" />
29-
<field path="section/payment_authorizenet_trans_key/value" value="" />
34+
<field path="carriers/usps/userid" value="" />
35+
<field path="carriers/usps/password" value="" />
3036

31-
<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_business_account/value" value="" />
32-
<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_api_username/value" value="" />
33-
<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_api_password/value" value="" />
34-
<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_api_signature/value" value="" />
37+
<field replace="carriers_dhl_id_us" value="" />
38+
<field replace="carriers_dhl_password_us" value="" />
39+
<field replace="carriers_dhl_account_us" value="" />
3540

36-
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_business_account/value" value="" />
37-
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_partner/value" value="" />
38-
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_user/value" value="" />
39-
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_pwd/value" value="" />
40-
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_vendor/value" value="" />
41+
<field replace="carriers_dhl_id_eu" value="" />
42+
<field replace="carriers_dhl_password_eu" value="" />
43+
<field replace="carriers_dhl_account_eu" value="" />
4144
</replace>
Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" ?>
1+
<?xml version="1.0"?>
22
<!--
33
/**
44
* Copyright © 2015 Magento. All rights reserved.
@@ -8,18 +8,63 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
99
<repository class="Magento\Config\Test\Repository\ConfigData">
1010
<dataset name="store_information">
11-
<field path="general/store_information/name" scope="general" scope_id="1" label="" xsi:type="string">Store 1</field>
12-
<field path="general/store_information/phone" scope="general" scope_id="1" label="" xsi:type="string">1234-123-123</field>
13-
<field path="general/store_information/country_id" scope="general" scope_id="1" label="United States" xsi:type="string">US</field>
14-
<field path="general/store_information/region_id" scope="general" scope_id="1" label="California" xsi:type="string">12</field>
15-
<field path="general/store_information/postcode" scope="general" scope_id="1" label="" xsi:type="string">90322</field>
16-
<field path="general/store_information/city" scope="general" scope_id="1" label="" xsi:type="string">Culver City</field>
17-
<field path="general/store_information/street_line1" scope="general" scope_id="1" label="" xsi:type="string">10441 Jefferson Blvd</field>
18-
<field path="general/store_information/street_line2" scope="general" scope_id="1" label="" xsi:type="string">Suite 200</field>
11+
<field name="general/store_information/name" xsi:type="array">
12+
<item name="scope" xsi:type="string">general</item>
13+
<item name="scope_id" xsi:type="number">1</item>
14+
<item name="label" xsi:type="string"/>
15+
<item name="value" xsi:type="string">Store 1</item>
16+
</field>
17+
<field name="general/store_information/phone" xsi:type="array">
18+
<item name="scope" xsi:type="string">general</item>
19+
<item name="scope_id" xsi:type="number">1</item>
20+
<item name="label" xsi:type="string"/>
21+
<item name="value" xsi:type="string">1234-123-123</item>
22+
</field>
23+
<field name="general/store_information/country_id" xsi:type="array">
24+
<item name="scope" xsi:type="string">general</item>
25+
<item name="scope_id" xsi:type="number">1</item>
26+
<item name="label" xsi:type="string">United States</item>
27+
<item name="value" xsi:type="string">US</item>
28+
</field>
29+
<field name="general/store_information/region_id" xsi:type="array">
30+
<item name="scope" xsi:type="string">general</item>
31+
<item name="scope_id" xsi:type="number">1</item>
32+
<item name="label" xsi:type="string">California</item>
33+
<item name="value" xsi:type="number">12</item>
34+
</field>
35+
<field name="general/store_information/postcode" xsi:type="array">
36+
<item name="scope" xsi:type="string">general</item>
37+
<item name="scope_id" xsi:type="number">1</item>
38+
<item name="label" xsi:type="string"/>
39+
<item name="value" xsi:type="number">90322</item>
40+
</field>
41+
<field name="general/store_information/city" xsi:type="array">
42+
<item name="scope" xsi:type="string">general</item>
43+
<item name="scope_id" xsi:type="number">1</item>
44+
<item name="label" xsi:type="string"/>
45+
<item name="value" xsi:type="string">Culver City</item>
46+
</field>
47+
<field name="general/store_information/street_line1" xsi:type="array">
48+
<item name="scope" xsi:type="string">general</item>
49+
<item name="scope_id" xsi:type="number">1</item>
50+
<item name="label" xsi:type="string"/>
51+
<item name="value" xsi:type="string">10441 Jefferson Blvd</item>
52+
</field>
53+
<field name="general/store_information/street_line2" xsi:type="array">
54+
<item name="scope" xsi:type="string">general</item>
55+
<item name="scope_id" xsi:type="number">1</item>
56+
<item name="label" xsi:type="string"/>
57+
<item name="value" xsi:type="string">Suite 200</item>
58+
</field>
1959
</dataset>
2060

2161
<dataset name="admin_session_lifetime_1_hour">
22-
<field path="admin/security/session_lifetime" scope="default" scope_id="0" label="3600" xsi:type="string">3600</field>
62+
<field name="admin/security/session_lifetime" xsi:type="array">
63+
<item name="scope" xsi:type="string">default</item>
64+
<item name="scope_id" xsi:type="number">0</item>
65+
<item name="label" xsi:type="number">3600</item>
66+
<item name="value" xsi:type="number">3600</item>
67+
</field>
2368
</dataset>
2469
</repository>
2570
</config>
Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" ?>
1+
<?xml version="1.0"?>
22
<!--
33
/**
44
* Copyright © 2015 Magento. All rights reserved.
@@ -8,19 +8,39 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
99
<repository class="Magento\Config\Test\Repository\ConfigData">
1010
<dataset name="display_out_of_stock">
11-
<field path="cataloginventory/options/show_out_of_stock" scope="cataloginventory" scope_id="1" label="Yes" xsi:type="string">1</field>
11+
<field name="cataloginventory/options/show_out_of_stock" xsi:type="array">
12+
<item name="scope" xsi:type="string">cataloginventory</item>
13+
<item name="scope_id" xsi:type="number">1</item>
14+
<item name="label" xsi:type="string">Yes</item>
15+
<item name="value" xsi:type="number">1</item>
16+
</field>
1217
</dataset>
1318

1419
<dataset name="backorders_allow_qty_below">
15-
<field path="cataloginventory/item_options/backorders" scope="cataloginventory" scope_id="1" label="Allow Qty Below 0" xsi:type="string">1</field>
20+
<field name="cataloginventory/item_options/backorders" xsi:type="array">
21+
<item name="scope" xsi:type="string">cataloginventory</item>
22+
<item name="scope_id" xsi:type="number">1</item>
23+
<item name="label" xsi:type="string">Allow Qty Below 0</item>
24+
<item name="value" xsi:type="number">1</item>
25+
</field>
1626
</dataset>
1727

1828
<dataset name="display_out_of_stock_rollback">
19-
<field path="cataloginventory/options/show_out_of_stock" scope="cataloginventory" scope_id="1" label="No" xsi:type="string">0</field>
29+
<field name="cataloginventory/options/show_out_of_stock" xsi:type="array">
30+
<item name="scope" xsi:type="string">cataloginventory</item>
31+
<item name="scope_id" xsi:type="number">1</item>
32+
<item name="label" xsi:type="string">No</item>
33+
<item name="value" xsi:type="number">0</item>
34+
</field>
2035
</dataset>
2136

2237
<dataset name="backorders_allow_qty_below_rollback">
23-
<field path="cataloginventory/item_options/backorders" scope="cataloginventory" scope_id="1" label="No Backorders" xsi:type="string">0</field>
38+
<field name="cataloginventory/item_options/backorders" xsi:type="array">
39+
<item name="scope" xsi:type="string">cataloginventory</item>
40+
<item name="scope_id" xsi:type="number">1</item>
41+
<item name="label" xsi:type="string">No Backorders</item>
42+
<item name="value" xsi:type="number">0</item>
43+
</field>
2444
</dataset>
2545
</repository>
2646
</config>

0 commit comments

Comments
 (0)