Skip to content

Commit 2430b3d

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-74208' into 2.2-develop-pr60
2 parents 63a0d40 + 164619a commit 2430b3d

File tree

60 files changed

+1733
-199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1733
-199
lines changed

app/code/Magento/Backend/Model/AdminPathConfig.php

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,38 @@ public function __construct(
4848
}
4949

5050
/**
51-
* {@inheritdoc}
52-
*
53-
* @param \Magento\Framework\App\RequestInterface $request
54-
* @return string
51+
* @inheritdoc
5552
*/
5653
public function getCurrentSecureUrl(\Magento\Framework\App\RequestInterface $request)
5754
{
5855
return $this->url->getBaseUrl('link', true) . ltrim($request->getPathInfo(), '/');
5956
}
6057

6158
/**
62-
* {@inheritdoc}
63-
*
64-
* @param string $path
65-
* @return bool
59+
* @inheritdoc
6660
*/
6761
public function shouldBeSecure($path)
6862
{
69-
return parse_url(
70-
(string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default'),
71-
PHP_URL_SCHEME
72-
) === 'https'
73-
|| $this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)
74-
&& parse_url(
75-
(string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default'),
76-
PHP_URL_SCHEME
77-
) === 'https';
63+
$baseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
64+
if (parse_url($baseUrl, PHP_URL_SCHEME) === 'https') {
65+
return true;
66+
}
67+
68+
if ($this->backendConfig->isSetFlag(Store::XML_PATH_SECURE_IN_ADMINHTML)) {
69+
if ($this->backendConfig->isSetFlag('admin/url/use_custom')) {
70+
$adminBaseUrl = (string)$this->coreConfig->getValue('admin/url/custom', 'default');
71+
} else {
72+
$adminBaseUrl = (string)$this->coreConfig->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
73+
}
74+
75+
return parse_url($adminBaseUrl, PHP_URL_SCHEME) === 'https';
76+
}
77+
78+
return false;
7879
}
7980

8081
/**
81-
* {@inheritdoc}
82-
*
83-
* @return string
82+
* @inheritdoc
8483
*/
8584
public function getDefaultPath()
8685
{

app/code/Magento/Backend/Test/Unit/Model/AdminPathConfigTest.php

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,35 @@ public function testGetCurrentSecureUrl()
7676
* @param $unsecureBaseUrl
7777
* @param $useSecureInAdmin
7878
* @param $secureBaseUrl
79+
* @param $useCustomUrl
80+
* @param $customUrl
7981
* @param $expected
8082
* @dataProvider shouldBeSecureDataProvider
8183
*/
82-
public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureBaseUrl, $expected)
83-
{
84-
$coreConfigValueMap = [
84+
public function testShouldBeSecure(
85+
$unsecureBaseUrl,
86+
$useSecureInAdmin,
87+
$secureBaseUrl,
88+
$useCustomUrl,
89+
$customUrl,
90+
$expected
91+
) {
92+
$coreConfigValueMap = $this->returnValueMap([
8593
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_URL, 'default', null, $unsecureBaseUrl],
8694
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_URL, 'default', null, $secureBaseUrl],
87-
];
88-
$this->coreConfig->expects($this->any())->method('getValue')->will($this->returnValueMap($coreConfigValueMap));
89-
$this->backendConfig->expects($this->any())->method('isSetFlag')->willReturn($useSecureInAdmin);
95+
['admin/url/custom', 'default', null, $customUrl],
96+
]);
97+
$backendConfigFlagsMap = $this->returnValueMap([
98+
[\Magento\Store\Model\Store::XML_PATH_SECURE_IN_ADMINHTML, $useSecureInAdmin],
99+
['admin/url/use_custom', $useCustomUrl],
100+
]);
101+
$this->coreConfig->expects($this->atLeast(1))->method('getValue')
102+
->will($coreConfigValueMap);
103+
$this->coreConfig->expects($this->atMost(2))->method('getValue')
104+
->will($coreConfigValueMap);
105+
106+
$this->backendConfig->expects($this->atMost(2))->method('isSetFlag')
107+
->will($backendConfigFlagsMap);
90108
$this->assertEquals($expected, $this->adminPathConfig->shouldBeSecure(''));
91109
}
92110

@@ -96,13 +114,13 @@ public function testShouldBeSecure($unsecureBaseUrl, $useSecureInAdmin, $secureB
96114
public function shouldBeSecureDataProvider()
97115
{
98116
return [
99-
['http://localhost/', false, 'default', false],
100-
['http://localhost/', true, 'default', false],
101-
['https://localhost/', false, 'default', true],
102-
['https://localhost/', true, 'default', true],
103-
['http://localhost/', false, 'https://localhost/', false],
104-
['http://localhost/', true, 'https://localhost/', true],
105-
['https://localhost/', true, 'https://localhost/', true],
117+
['http://localhost/', false, 'default', false, '', false],
118+
['http://localhost/', true, 'default', false, '', false],
119+
['https://localhost/', false, 'default', false, '', true],
120+
['https://localhost/', true, 'default', false, '', true],
121+
['http://localhost/', false, 'https://localhost/', false, '', false],
122+
['http://localhost/', true, 'https://localhost/', false, '', true],
123+
['https://localhost/', true, 'https://localhost/', false, '', true],
106124
];
107125
}
108126

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Bundle\Model\Plugin;
9+
10+
use Magento\Quote\Model\Quote\Item as OrigQuoteItem;
11+
use Magento\Quote\Model\Quote\Item\AbstractItem;
12+
use Magento\Framework\Serialize\SerializerInterface;
13+
14+
/**
15+
* Update prices stored in quote item options after calculating quote item's totals.
16+
*/
17+
class UpdatePriceInQuoteItemOptions
18+
{
19+
/**
20+
* @var SerializerInterface
21+
*/
22+
private $serializer;
23+
24+
/**
25+
* @param SerializerInterface $serializer
26+
*/
27+
public function __construct(SerializerInterface $serializer)
28+
{
29+
$this->serializer = $serializer;
30+
}
31+
32+
/**
33+
* Update price on quote item options level
34+
*
35+
* @param OrigQuoteItem $subject
36+
* @param AbstractItem $result
37+
* @return AbstractItem
38+
*
39+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
40+
*/
41+
public function afterCalcRowTotal(OrigQuoteItem $subject, AbstractItem $result): AbstractItem
42+
{
43+
$bundleAttributes = $result->getProduct()->getCustomOption('bundle_selection_attributes');
44+
if ($bundleAttributes !== null) {
45+
$actualAmount = $result->getPrice() * $result->getQty();
46+
$parsedValue = $this->serializer->unserialize($bundleAttributes->getValue());
47+
if (is_array($parsedValue) && array_key_exists('price', $parsedValue)) {
48+
$parsedValue['price'] = $actualAmount;
49+
}
50+
$bundleAttributes->setValue($this->serializer->serialize($parsedValue));
51+
}
52+
53+
return $result;
54+
}
55+
}

app/code/Magento/Bundle/Model/Product/Type.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ protected function _prepareProduct(\Magento\Framework\DataObject $buyRequest, $p
741741
$price = $product->getPriceModel()
742742
->getSelectionFinalTotalPrice($product, $selection, 0, $qty);
743743
$attributes = [
744-
'price' => $this->priceCurrency->convert($price),
744+
'price' => $price,
745745
'qty' => $qty,
746746
'option_label' => $selection->getOption()
747747
->getTitle(),

app/code/Magento/Bundle/Test/Mftf/ActionGroup/BundleProductsOnAdminActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,8 @@
4747
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
4848
<click selector="{{AdminProductGridActionSection.addBundleProduct}}" stepKey="goToNewBundleProductPage"/>
4949
</actionGroup>
50+
51+
<actionGroup name="CreateBundleProductForTwoSimpleProductsWithRadioTypeOptions" extends="CreateBundleProductForTwoSimpleProducts">
52+
<selectOption selector="{{AdminProductFormBundleSection.bundleOptionXInputType('0')}}" userInput="Radio Buttons" after="fillOptionTitle" stepKey="selectInputType"/>
53+
</actionGroup>
5054
</actionGroups>

app/code/Magento/Bundle/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,20 @@
2323
<waitForText userInput="{{quantity}}" selector="{{StorefrontMinicartSection.productCount}}" time="30" stepKey="assertProductCount"/>
2424
<see userInput="You added {{product.name}} to your shopping cart." selector="{{StorefrontMessagesSection.success}}" stepKey="seeSuccessMessage"/>
2525
</actionGroup>
26+
<!-- Add Bundle Product to Cart with specified currency -->
27+
<actionGroup name="StoreFrontAddProductToCartFromBundleWithCurrencyActionGroup">
28+
<arguments>
29+
<argument name="product"/>
30+
<argument name="currency" type="string" defaultValue="US Dollar"/>
31+
</arguments>
32+
<click selector="{{StorefrontHeaderCurrencySwitcherSection.currencyTrigger}}" stepKey="openCurrencyTrigger"/>
33+
<click selector="{{StorefrontHeaderCurrencySwitcherSection.currency(currency)}}" stepKey="chooseCurrency"/>
34+
<waitForPageLoad stepKey="waitForCurrencyChange"/>
35+
<click selector="{{StorefrontBundledSection.addToCart}}" stepKey="clickCustomize"/>
36+
<waitForPageLoad stepKey="waitForBundleOpen"/>
37+
<checkOption selector="{{StorefrontBundledSection.bundleOptionByName(product.name)}}" stepKey="chooseProduct"/>
38+
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="addToCartProduct"/>
39+
<waitForAjaxLoad stepKey="waitForLoad"/>
40+
<scrollToTopOfPage stepKey="scrollToTop"/>
41+
</actionGroup>
2642
</actionGroups>

app/code/Magento/Bundle/Test/Mftf/Data/BundleProductData.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
<data key="name" unique="suffix">BundleProduct</data>
1818
<data key="sku" unique="suffix">BundleProduct</data>
1919
<data key="status">1</data>
20+
<data key="set">4</data>
21+
<data key="type">bundle</data>
2022
<data key="urlKey" unique="suffix">bundleproduct</data>
2123
<data key="visibility">4</data>
2224
<data key="option_title" unique="suffix">TestOption</data>

app/code/Magento/Bundle/Test/Mftf/Section/StorefrontBundledSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
1111
<section name="StorefrontBundledSection">
1212
<element name="bundleOption" type="input" selector=".option:nth-of-type({{numOption}}) .choice:nth-of-type({{numOptionSelect}}) input" parameterized="true"/>
13+
<element name="bundleOptionByName" type="input" selector="//div[@class='field choice']//span[@class='product-name'][contains(text(),'{{name}}')]/../../../input" parameterized="true"/>
1314
<element name="addToCart" type="button" selector="#bundle-slide" timeout="30"/>
1415
<element name="addToCartConfigured" type="button" selector="#product-addtocart-button" timeout="30"/>
1516
<element name="updateCart" type="button" selector="#product-updatecart-button" timeout="30"/>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="CurrencyChangingBundleProductInCartTest">
11+
<annotations>
12+
<features value="Bundle"/>
13+
<stories value="MAGETWO-90381: Bundle product price doubled when switching currency"/>
14+
<title value="Work of currency changing with a bundle product added to the cart"/>
15+
<description value="User should be able change the currency and add one more product in cart and get right price in previous currency"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-96305"/>
18+
<group value="Bundle"/>
19+
</annotations>
20+
<before>
21+
<actionGroup ref="LoginAsAdmin" stepKey="login" />
22+
<createData entity="CurrencySettingWithEuroAndUSD" stepKey="configureCurrencyOptions"/>
23+
<createData entity="_defaultCategory" stepKey="createPreReqCategory"/>
24+
<createData entity="SimpleProduct" stepKey="createPreReqSimpleProduct1">
25+
<requiredEntity createDataKey="createPreReqCategory"/>
26+
</createData>
27+
<createData entity="SimpleProduct2" stepKey="createPreReqSimpleProduct2">
28+
<requiredEntity createDataKey="createPreReqCategory"/>
29+
</createData>
30+
</before>
31+
<after>
32+
<deleteData createDataKey="createPreReqCategory" stepKey="deletePreReqCategory"/>
33+
<deleteData createDataKey="createPreReqSimpleProduct1" stepKey="deletePreReqSimpleProduct1"/>
34+
<deleteData createDataKey="createPreReqSimpleProduct2" stepKey="deletePreReqSimpleProduct2"/>
35+
<createData entity="DefaultCurrencySetting" stepKey="restoreCurrencyOptions"/>
36+
<!-- Delete the bundled product -->
37+
<actionGroup ref="deleteProductUsingProductGrid" stepKey="deleteProductOnProductsGridPageByName">
38+
<argument name="product" value="BundleProduct"/>
39+
</actionGroup>
40+
<!--Clear Configs-->
41+
<actionGroup ref="logout" stepKey="logout"/>
42+
</after>
43+
<!-- Navigate to the Products>Inventory>Catalog -->
44+
<!-- Click on "+" dropdown and select Bundle Product type -->
45+
<actionGroup ref="OpenNewBundleProductPage" stepKey="openNewBundleProductPage"/>
46+
<!-- Add Option, a "Radio Buttons" type option -->
47+
<actionGroup ref="CreateBundleProductForTwoSimpleProductsWithRadioTypeOptions" stepKey="addBundleOptionWithTwoProducts2">
48+
<argument name="bundleProduct" value="BundleProduct"/>
49+
<argument name="simpleProductFirst" value="$$createPreReqSimpleProduct1$$"/>
50+
<argument name="simpleProductSecond" value="$$createPreReqSimpleProduct2$$"/>
51+
</actionGroup>
52+
<!-- Save product -->
53+
<actionGroup ref="SaveProductOnProductPageOnAdmin" stepKey="saveProductOnProductPageOnAdmin"/>
54+
<!-- Go to storefront BundleProduct -->
55+
<amOnPage url="{{StorefrontProductPage.url(BundleProduct.name)}}" stepKey="goToStorefrontProductPage"/>
56+
<waitForPageLoad stepKey="waitForStorefrontProductPage"/>
57+
<actionGroup ref="StoreFrontAddProductToCartFromBundleWithCurrencyActionGroup" stepKey="addProduct1ToCartAndChangeCurrencyToEuro">
58+
<argument name="product" value="$$createPreReqSimpleProduct1$$"/>
59+
<argument name="currency" value="EUR - Euro"/>
60+
</actionGroup>
61+
<actionGroup ref="StoreFrontAddProductToCartFromBundleWithCurrencyActionGroup" stepKey="addProduct2ToCartAndChangeCurrencyToUSD">
62+
<argument name="product" value="$$createPreReqSimpleProduct1$$"/>
63+
<argument name="currency" value="USD - US Dollar"/>
64+
</actionGroup>
65+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="openMiniCart"/>
66+
<waitForPageLoad stepKey="waitForMiniCart"/>
67+
<see selector="{{StorefrontMinicartSection.miniCartSubtotalField}}" userInput="$4,000.00" stepKey="seeCartSubtotal"/>
68+
</test>
69+
</tests>

0 commit comments

Comments
 (0)