Skip to content

Commit c2500fa

Browse files
Merge remote-tracking branch 'remotes/github/MAGETWO-96421' into EPAM-PR-40
2 parents b06ab90 + b623211 commit c2500fa

File tree

13 files changed

+203
-15
lines changed

13 files changed

+203
-15
lines changed

app/code/Magento/Checkout/Block/Cart/Sidebar.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,14 @@ public function getConfig()
8282
'baseUrl' => $this->getBaseUrl(),
8383
'minicartMaxItemsVisible' => $this->getMiniCartMaxItemsCount(),
8484
'websiteId' => $this->_storeManager->getStore()->getWebsiteId(),
85-
'maxItemsToDisplay' => $this->getMaxItemsToDisplay()
85+
'maxItemsToDisplay' => $this->getMaxItemsToDisplay(),
86+
'storeId' => $this->_storeManager->getStore()->getId()
8687
];
8788
}
8889

8990
/**
91+
* Get serialized config
92+
*
9093
* @return string
9194
* @since 100.2.0
9295
*/
@@ -96,6 +99,8 @@ public function getSerializedConfig()
9699
}
97100

98101
/**
102+
* Get image html template
103+
*
99104
* @return string
100105
*/
101106
public function getImageHtmlTemplate()
@@ -130,6 +135,7 @@ public function getShoppingCartUrl()
130135
*
131136
* @return string
132137
* @codeCoverageIgnore
138+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
133139
*/
134140
public function getUpdateItemQtyUrl()
135141
{
@@ -141,6 +147,7 @@ public function getUpdateItemQtyUrl()
141147
*
142148
* @return string
143149
* @codeCoverageIgnore
150+
* @SuppressWarnings(PHPMD.RequestAwareBlockMethod)
144151
*/
145152
public function getRemoveItemUrl()
146153
{
@@ -210,6 +217,7 @@ private function getMiniCartMaxItemsCount()
210217

211218
/**
212219
* Returns maximum cart items to display
220+
*
213221
* This setting regulates how many items will be displayed in minicart
214222
*
215223
* @return int

app/code/Magento/Checkout/CustomerData/Cart.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/**
1212
* Cart source
13+
*
14+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
1315
*/
1416
class Cart extends \Magento\Framework\DataObject implements SectionSourceInterface
1517
{
@@ -98,7 +100,8 @@ public function getSectionData()
98100
'items' => $this->getRecentItems(),
99101
'extra_actions' => $this->layout->createBlock(\Magento\Catalog\Block\ShortcutButtons::class)->toHtml(),
100102
'isGuestCheckoutAllowed' => $this->isGuestCheckoutAllowed(),
101-
'website_id' => $this->getQuote()->getStore()->getWebsiteId()
103+
'website_id' => $this->getQuote()->getStore()->getWebsiteId(),
104+
'storeId' => $this->getQuote()->getStore()->getStoreId()
102105
];
103106
}
104107

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
parameterized="true"/>
2727
<element name="RemoveItem" type="button"
2828
selector="//table[@id='shopping-cart-table']//tbody//tr[contains(@class,'item-actions')]//a[contains(@class,'action-delete')]"/>
29+
<element name="productName" type="text" selector="//tbody[@class='cart item']//strong[@class='product-item-name']"/>
2930
<element name="nthItemOption" type="block" selector=".item:nth-of-type({{numElement}}) .item-options" parameterized="true"/>
3031
<element name="nthEditButton" type="block" selector=".item:nth-of-type({{numElement}}) .action-edit" parameterized="true"/>
3132
<element name="nthBundleOptionName" type="text" selector=".product-item-details .item-options:nth-of-type({{numOption}}) dt" parameterized="true"/>

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingGuestInfoSection.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@
1919
<element name="telephone" type="input" selector="input[name=telephone]"/>
2020
<element name="next" type="button" selector="button.button.action.continue.primary" timeout="30"/>
2121
<element name="firstShippingMethod" type="radio" selector=".row:nth-of-type(1) .col-method .radio"/>
22+
23+
<!--Order Summary-->
24+
<element name="itemInCart" type="button" selector="//div[@class='title']"/>
25+
<element name="productName" type="text" selector="//strong[@class='product-item-name']"/>
2226
</section>
2327
</sections>

app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<element name="productLinkByName" type="button" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details']//a[contains(text(), '{{var1}}')]" parameterized="true"/>
1414
<element name="productPriceByName" type="text" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details'][.//a[contains(text(), '{{var1}}')]]//span[@class='price']" parameterized="true"/>
1515
<element name="productImageByName" type="text" selector="//header//ol[@id='mini-cart']//span[@class='product-image-container']//img[@alt='{{var1}}']" parameterized="true"/>
16+
<element name="productName" type="text" selector=".product-item-name"/>
1617
<element name="productOptionsDetailsByName" type="button" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details'][.//a[contains(text(), '{{var1}}')]]//span[.='See Details']" parameterized="true"/>
1718
<element name="productOptionByNameAndAttribute" type="text" selector="//header//ol[@id='mini-cart']//div[@class='product-item-details'][.//a[contains(text(), '{{var1}}')]]//dt[@class='label' and .='{{var2}}']/following-sibling::dd[@class='values']//span" parameterized="true"/>
1819
<element name="showCart" type="button" selector="a.showcart"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="StorefrontProductNameMinicartOnCheckoutPageDifferentStoreViewsTest">
12+
<annotations>
13+
<features value="Checkout"/>
14+
<title value="Checking Product name in Minicart and on Checkout page with different store views"/>
15+
<description value="Checking Product name in Minicart and on Checkout page with different store views"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MAGETWO-96466"/>
18+
<useCaseId value="MAGETWO-96421"/>
19+
<group value="checkout"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
24+
<!--Create a product-->
25+
<createData entity="SimpleProduct2" stepKey="createProduct"/>
26+
</before>
27+
<after>
28+
<!--Delete created data-->
29+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
30+
<actionGroup ref="AdminDeleteStoreViewActionGroup" stepKey="deleteStoreView">
31+
<argument name="customStore" value="customStore"/>
32+
</actionGroup>
33+
34+
<actionGroup ref="logout" stepKey="logout"/>
35+
</after>
36+
37+
<!-- Create store view -->
38+
<actionGroup ref="AdminCreateStoreViewActionGroup" stepKey="createStoreView">
39+
<argument name="customStore" value="customStore"/>
40+
</actionGroup>
41+
42+
<!--Go to created product page-->
43+
<amOnPage url="{{AdminProductEditPage.url($$createProduct.id$$)}}" stepKey="goToEditPage"/>
44+
<waitForPageLoad stepKey="waitForProductPage"/>
45+
46+
<!--Switch to second store view and change the product name-->
47+
<actionGroup ref="SwitchToTheNewStoreView" stepKey="switchToCustomStoreView">
48+
<argument name="storeViewName" value="{{customStore.name}}"/>
49+
</actionGroup>
50+
<waitForPageLoad stepKey="waitForPageLoad"/>
51+
<click selector="{{AdminProductFormSection.productNameUseDefault}}" stepKey="uncheckUseDefault"/>
52+
<fillField selector="{{AdminProductFormSection.productName}}" userInput="$$createProduct.name$$-new" stepKey="fillProductName"/>
53+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="saveProduct"/>
54+
55+
<!--Add product to cart-->
56+
<amOnPage url="{{StorefrontProductPage.url($$createProduct.name$$)}}" stepKey="amOnSimpleProductPage"/>
57+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
58+
<actionGroup ref="addToCartFromStorefrontProductPage" stepKey="addToCartFromStorefrontProductPage">
59+
<argument name="productName" value="$createProduct.name$$"/>
60+
</actionGroup>
61+
62+
<!--Switch to second store view-->
63+
<actionGroup ref="StorefrontSwitchStoreViewActionGroup" stepKey="switchStoreView">
64+
<argument name="storeView" value="customStore"/>
65+
</actionGroup>
66+
<waitForPageLoad stepKey="waitForStoreView"/>
67+
68+
<!--Check product name in Minicart-->
69+
<click selector="{{StorefrontMinicartSection.showCart}}" stepKey="clickCart"/>
70+
<grabTextFrom selector="{{StorefrontMinicartSection.productName}}" stepKey="grabProductNameMinicart"/>
71+
<assertContains expected="$$createProduct.name$$" actual="$grabProductNameMinicart" stepKey="assertProductNameMinicart"/>
72+
<assertContains expectedType="string" expected="-new" actual="$grabProductNameMinicart" stepKey="assertProductNameMinicart1"/>
73+
74+
<!--Check product name in Shopping Cart page-->
75+
<click selector="{{StorefrontMinicartSection.viewAndEditCart}}" stepKey="clickViewAndEdit"/>
76+
<waitForPageLoad stepKey="waitForShoppingCartPageLoad"/>
77+
<grabTextFrom selector="{{CheckoutCartProductSection.productName}}" stepKey="grabProductNameCart"/>
78+
<assertContains expected="$$createProduct.name$$" actual="$grabProductNameCart" stepKey="assertProductNameCart"/>
79+
<assertContains expectedType="string" expected="-new" actual="$grabProductNameCart" stepKey="assertProductNameCart1"/>
80+
81+
<!--Proceed to checkout and check product name in Order Summary area-->
82+
<click selector="{{CheckoutCartSummarySection.proceedToCheckout}}" stepKey="proceedToCheckout"/>
83+
<waitForPageLoad stepKey="waitForShippingPageLoad"/>
84+
<click selector="{{CheckoutShippingGuestInfoSection.itemInCart}}" stepKey="clickItemInCart"/>
85+
<grabTextFrom selector="{{CheckoutShippingGuestInfoSection.productName}}" stepKey="grabProductNameShipping"/>
86+
<assertContains expected="$$createProduct.name$$" actual="$grabProductNameShipping" stepKey="assertProductNameShipping"/>
87+
<assertContains expectedType="string" expected="-new" actual="$grabProductNameShipping" stepKey="assertProductNameShipping1"/>
88+
</test>
89+
</tests>

app/code/Magento/Checkout/Test/Unit/Block/Cart/SidebarTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ public function testGetConfig()
144144
'baseUrl' => $baseUrl,
145145
'minicartMaxItemsVisible' => 3,
146146
'websiteId' => 100,
147-
'maxItemsToDisplay' => 8
147+
'maxItemsToDisplay' => 8,
148+
'storeId' => null
148149
];
149150

150151
$valueMap = [
@@ -161,7 +162,7 @@ public function testGetConfig()
161162
$this->urlBuilderMock->expects($this->exactly(4))
162163
->method('getUrl')
163164
->willReturnMap($valueMap);
164-
$this->storeManagerMock->expects($this->exactly(2))->method('getStore')->willReturn($storeMock);
165+
$this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($storeMock);
165166
$storeMock->expects($this->once())->method('getBaseUrl')->willReturn($baseUrl);
166167

167168
$this->scopeConfigMock->expects($this->at(0))

app/code/Magento/Checkout/Test/Unit/CustomerData/CartTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testGetSectionData()
113113

114114
$storeMock = $this->createPartialMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId']);
115115
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
116-
$quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock);
116+
$quoteMock->expects($this->any())->method('getStore')->willReturn($storeMock);
117117

118118
$productMock = $this->createPartialMock(
119119
\Magento\Catalog\Model\Product::class,
@@ -162,6 +162,7 @@ public function testGetSectionData()
162162
'isGuestCheckoutAllowed' => 1,
163163
'website_id' => $websiteId,
164164
'subtotalAmount' => 200,
165+
'storeId' => null
165166
];
166167
$this->assertEquals($expectedResult, $this->model->getSectionData());
167168
}
@@ -199,7 +200,7 @@ public function testGetSectionDataWithCompositeProduct()
199200

200201
$storeMock = $this->createPartialMock(\Magento\Store\Model\System\Store::class, ['getWebsiteId']);
201202
$storeMock->expects($this->once())->method('getWebsiteId')->willReturn($websiteId);
202-
$quoteMock->expects($this->once())->method('getStore')->willReturn($storeMock);
203+
$quoteMock->expects($this->any())->method('getStore')->willReturn($storeMock);
203204

204205
$this->checkoutCartMock->expects($this->once())->method('getSummaryQty')->willReturn($summaryQty);
205206
$this->checkoutHelperMock->expects($this->once())
@@ -265,6 +266,7 @@ public function testGetSectionDataWithCompositeProduct()
265266
'isGuestCheckoutAllowed' => 1,
266267
'website_id' => $websiteId,
267268
'subtotalAmount' => 200,
269+
'storeId' => null
268270
];
269271
$this->assertEquals($expectedResult, $this->model->getSectionData());
270272
}

app/code/Magento/Checkout/view/frontend/web/js/view/minicart.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ define([
8181
maxItemsToDisplay: window.checkout.maxItemsToDisplay,
8282
cart: {},
8383

84+
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
8485
/**
8586
* @override
8687
*/
@@ -101,12 +102,16 @@ define([
101102
self.isLoading(true);
102103
});
103104

104-
if (cartData()['website_id'] !== window.checkout.websiteId) {
105+
if (cartData().website_id !== window.checkout.websiteId ||
106+
cartData().store_id !== window.checkout.storeId
107+
) {
105108
customerData.reload(['cart'], false);
106109
}
107110

108111
return this._super();
109112
},
113+
//jscs:enable requireCamelCaseOrUpperCaseIdentifiers
114+
110115
isLoading: ko.observable(false),
111116
initSidebar: initSidebar,
112117

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/Cart.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(
7171
}
7272

7373
/**
74-
* {@inheritdoc}
74+
* @inheritdoc
7575
*/
7676
protected function _construct()
7777
{
@@ -94,7 +94,7 @@ protected function _prepareCollection()
9494
$quote = $this->getQuote();
9595

9696
if ($quote) {
97-
$collection = $quote->getItemsCollection(false);
97+
$collection = $quote->getItemsCollection(true);
9898
} else {
9999
$collection = $this->_dataCollectionFactory->create();
100100
}
@@ -106,7 +106,7 @@ protected function _prepareCollection()
106106
}
107107

108108
/**
109-
* {@inheritdoc}
109+
* @inheritdoc
110110
*/
111111
protected function _prepareColumns()
112112
{
@@ -144,15 +144,15 @@ protected function _prepareColumns()
144144
}
145145

146146
/**
147-
* {@inheritdoc}
147+
* @inheritdoc
148148
*/
149149
public function getRowUrl($row)
150150
{
151151
return $this->getUrl('catalog/product/edit', ['id' => $row->getProductId()]);
152152
}
153153

154154
/**
155-
* {@inheritdoc}
155+
* @inheritdoc
156156
*/
157157
public function getHeadersVisibility()
158158
{

0 commit comments

Comments
 (0)