Skip to content

Commit

Permalink
Merge pull request #230 from magento-firedrakes/MAGETWO-35629
Browse files Browse the repository at this point in the history
[Firedrakes] Bug fixes
  • Loading branch information
sivaschenko committed Apr 15, 2015
2 parents 927e8e2 + 98c6cda commit 07f9f16
Show file tree
Hide file tree
Showing 28 changed files with 2,784 additions and 573 deletions.
12 changes: 11 additions & 1 deletion app/code/Magento/Quote/Model/Quote.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
* sales_quote_delete_after
*
* @method Quote setStoreId(int $value)
* @method Quote setIsVirtual(int $value)
* @method int getIsMultiShipping()
* @method Quote setIsMultiShipping(int $value)
* @method float getStoreToBaseRate()
Expand Down Expand Up @@ -556,6 +555,14 @@ public function setIsActive($isActive)
return $this->setData(self::KEY_IS_ACTIVE, $isActive);
}

/**
* {@inheritdoc}
*/
public function setIsVirtual($isVirtual)
{
return $this->setData(self::KEY_IS_VIRTUAL, $isVirtual);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -772,6 +779,9 @@ public function beforeSave()
$this->setCustomerId($this->_customer->getId());
}

//mark quote if it has virtual products only
$this->setIsVirtual($this->getIsVirtual());

parent::beforeSave();
}

Expand Down
91 changes: 91 additions & 0 deletions app/code/Magento/Quote/Test/Unit/Model/QuoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Magento\Quote\Model\Quote\Address;
use Magento\Store\Model\ScopeInterface;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;

/**
Expand Down Expand Up @@ -1040,4 +1041,94 @@ public function testAddItem()

$this->quote->addItem($item);
}

/**
* @param array $productTypes
* @param int $expected
* @dataProvider dataProviderForTestBeforeSaveIsVirtualQuote
*/
public function testBeforeSaveIsVirtualQuote(array $productTypes, $expected)
{
$storeId = 1;
$currencyMock = $this->getMockBuilder('Magento\Directory\Model\Currency')
->disableOriginalConstructor()
->getMock();
$currencyMock->expects($this->any())
->method('getCode')
->will($this->returnValue('test_code'));
$currencyMock->expects($this->any())
->method('getRate')
->will($this->returnValue('test_rate'));
$storeMock = $this->getMockBuilder('Magento\Store\Model\Store')
->disableOriginalConstructor()
->getMock();
$storeMock->expects($this->once())
->method('getBaseCurrency')
->will($this->returnValue($currencyMock));
$storeMock->expects($this->once())
->method('getCurrentCurrency')
->will($this->returnValue($currencyMock));

$this->storeManagerMock->expects($this->any())
->method('getStore')
->with($storeId)
->will($this->returnValue($storeMock));
$this->quote->setStoreId($storeId);

$collectionMock = $this->getMock(
'Magento\Quote\Model\Resource\Quote\Item\Collection',
[],
[],
'',
false
);
$items = [];
foreach ($productTypes as $type) {
$productMock = $this->getMock('\Magento\Catalog\Model\Product', [], [], '', false);;
$productMock->expects($this->any())->method('getIsVirtual')->willReturn($type);

$itemMock = $this->getMock(
'Magento\Quote\Model\Quote\Item',
['isDeleted', 'getParentItemId', 'getProduct'],
[],
'',
false
);
$itemMock->expects($this->any())
->method('isDeleted')
->willReturn(false);
$itemMock->expects($this->any())
->method('getParentItemId')
->willReturn(false);
$itemMock->expects($this->any())
->method('getProduct')
->willReturn($productMock);
$items[] = $itemMock;
}
$iterator = new \ArrayIterator($items);
$collectionMock->expects($this->any())
->method('getIterator')
->will($this->returnValue($iterator));
$this->quoteItemCollectionFactoryMock->expects($this->once())
->method('create')
->will($this->returnValue($collectionMock));

$this->quote->beforeSave();
$this->assertEquals($expected, $this->quote->getDataByKey(CartInterface::KEY_IS_VIRTUAL));
}


/**
* @return array
*/
public function dataProviderForTestBeforeSaveIsVirtualQuote()
{
return [
[[true], 1],
[[true, true], 1],
[[false], 0],
[[true, false], 0],
[[false, false], 0]
];
}
}
2 changes: 1 addition & 1 deletion dev/tests/functional/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"magento/mtf": "1.0.0-rc21",
"magento/mtf": "1.0.0-rc22",
"php": "~5.5.0|~5.6.0",
"phpunit/phpunit": "4.1.0",
"phpunit/phpunit-selenium": ">=1.2",
Expand Down
51 changes: 27 additions & 24 deletions dev/tests/functional/credentials.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,38 @@
-->
<replace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/magento/mtf/Magento/Mtf/Fixture/InjectableFixture/etc/replace.xsd">
<field path="carriers/fedex/account" value="" />
<field path="carriers/fedex/meter_number" value="" />
<field path="carriers/fedex/key" value="" />
<field path="carriers/fedex/password" value="" />

<field path="section/carriers_dhl_id/value" value="" />
<field path="section/carriers_dhl_password/value" value="" />
<field path="section/carriers_dhl_account/value" value="" />
<field path="payment/authorizenet/login" value="" />
<field path="payment/authorizenet/trans_key" value="" />

<field path="section/carriers_fedex_account/value" value="" />
<field path="section/carriers_fedex_meter_number/value" value="" />
<field path="section/carriers_fedex_key/value" value="" />
<field path="section/carriers_fedex_password/value" value="" />
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/business_account" value="" />
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_username" value="" />
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_password" value="" />
<field path="payment/paypal_group_all_in_one/wpp_usuk/wpp_required_settings/wpp_and_express_checkout/api_signature" value="" />

<field path="section/carriers_ups_password/value" value="" />
<field path="section/carriers_ups_username/value" value="" />
<field path="section/carriers_ups_access_license_number/value" value="" />
<field path="section/carriers_ups_shipper_number/value" value="" />
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/business_account" value="" />
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/partner" value="" />
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/user" value="" />
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/pwd" value="" />
<field path="payment/paypal_payment_gateways/paypal_payflowpro_with_express_checkout/paypal_payflow_required/paypal_payflow_api_settings/vendor" value="" />

<field path="section/carriers_usps_userid/value" value="" />
<field path="section/carriers_usps_password/value" value="" />
<field path="carriers/ups/password" value="" />
<field path="carriers/ups/username" value="" />
<field path="carriers/ups/access_license_number" value="" />
<field path="carriers/ups/shipper_number" value="" />

<field path="section/payment_authorizenet_login/value" value="" />
<field path="section/payment_authorizenet_trans_key/value" value="" />
<field path="carriers/usps/userid" value="" />
<field path="carriers/usps/password" value="" />

<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_business_account/value" value="" />
<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_api_username/value" value="" />
<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_api_password/value" value="" />
<field path="section/payment_paypal_group_all_in_one_wpp_usuk_wpp_required_settings_wpp_and_express_checkout_api_signature/value" value="" />
<field replace="carriers_dhl_id_us" value="" />
<field replace="carriers_dhl_password_us" value="" />
<field replace="carriers_dhl_account_us" value="" />

<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_business_account/value" value="" />
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_partner/value" value="" />
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_user/value" value="" />
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_pwd/value" value="" />
<field path="section/payment_paypal_payment_gateways_paypal_payflowpro_with_express_checkout_paypal_payflow_required_paypal_payflow_api_settings_vendor/value" value="" />
<field replace="carriers_dhl_id_eu" value="" />
<field replace="carriers_dhl_password_eu" value="" />
<field replace="carriers_dhl_account_eu" value="" />
</replace>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
Expand All @@ -8,18 +8,63 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
<repository class="Magento\Config\Test\Repository\ConfigData">
<dataset name="store_information">
<field path="general/store_information/name" scope="general" scope_id="1" label="" xsi:type="string">Store 1</field>
<field path="general/store_information/phone" scope="general" scope_id="1" label="" xsi:type="string">1234-123-123</field>
<field path="general/store_information/country_id" scope="general" scope_id="1" label="United States" xsi:type="string">US</field>
<field path="general/store_information/region_id" scope="general" scope_id="1" label="California" xsi:type="string">12</field>
<field path="general/store_information/postcode" scope="general" scope_id="1" label="" xsi:type="string">90322</field>
<field path="general/store_information/city" scope="general" scope_id="1" label="" xsi:type="string">Culver City</field>
<field path="general/store_information/street_line1" scope="general" scope_id="1" label="" xsi:type="string">10441 Jefferson Blvd</field>
<field path="general/store_information/street_line2" scope="general" scope_id="1" label="" xsi:type="string">Suite 200</field>
<field name="general/store_information/name" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">Store 1</item>
</field>
<field name="general/store_information/phone" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">1234-123-123</item>
</field>
<field name="general/store_information/country_id" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">United States</item>
<item name="value" xsi:type="string">US</item>
</field>
<field name="general/store_information/region_id" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">California</item>
<item name="value" xsi:type="number">12</item>
</field>
<field name="general/store_information/postcode" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="number">90322</item>
</field>
<field name="general/store_information/city" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">Culver City</item>
</field>
<field name="general/store_information/street_line1" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">10441 Jefferson Blvd</item>
</field>
<field name="general/store_information/street_line2" xsi:type="array">
<item name="scope" xsi:type="string">general</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string"/>
<item name="value" xsi:type="string">Suite 200</item>
</field>
</dataset>

<dataset name="admin_session_lifetime_1_hour">
<field path="admin/security/session_lifetime" scope="default" scope_id="0" label="3600" xsi:type="string">3600</field>
<field name="admin/security/session_lifetime" xsi:type="array">
<item name="scope" xsi:type="string">default</item>
<item name="scope_id" xsi:type="number">0</item>
<item name="label" xsi:type="number">3600</item>
<item name="value" xsi:type="number">3600</item>
</field>
</dataset>
</repository>
</config>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
Expand All @@ -8,19 +8,39 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
<repository class="Magento\Config\Test\Repository\ConfigData">
<dataset name="display_out_of_stock">
<field path="cataloginventory/options/show_out_of_stock" scope="cataloginventory" scope_id="1" label="Yes" xsi:type="string">1</field>
<field name="cataloginventory/options/show_out_of_stock" xsi:type="array">
<item name="scope" xsi:type="string">cataloginventory</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">Yes</item>
<item name="value" xsi:type="number">1</item>
</field>
</dataset>

<dataset name="backorders_allow_qty_below">
<field path="cataloginventory/item_options/backorders" scope="cataloginventory" scope_id="1" label="Allow Qty Below 0" xsi:type="string">1</field>
<field name="cataloginventory/item_options/backorders" xsi:type="array">
<item name="scope" xsi:type="string">cataloginventory</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">Allow Qty Below 0</item>
<item name="value" xsi:type="number">1</item>
</field>
</dataset>

<dataset name="display_out_of_stock_rollback">
<field path="cataloginventory/options/show_out_of_stock" scope="cataloginventory" scope_id="1" label="No" xsi:type="string">0</field>
<field name="cataloginventory/options/show_out_of_stock" xsi:type="array">
<item name="scope" xsi:type="string">cataloginventory</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">No</item>
<item name="value" xsi:type="number">0</item>
</field>
</dataset>

<dataset name="backorders_allow_qty_below_rollback">
<field path="cataloginventory/item_options/backorders" scope="cataloginventory" scope_id="1" label="No Backorders" xsi:type="string">0</field>
<field name="cataloginventory/item_options/backorders" xsi:type="array">
<item name="scope" xsi:type="string">cataloginventory</item>
<item name="scope_id" xsi:type="number">1</item>
<item name="label" xsi:type="string">No Backorders</item>
<item name="value" xsi:type="number">0</item>
</field>
</dataset>
</repository>
</config>
Loading

0 comments on commit 07f9f16

Please sign in to comment.