Skip to content

Commit e683445

Browse files
merge magento/2.3-develop into magento-pangolin/community-tests-migration-pr
2 parents f24e3e8 + 7d23e3f commit e683445

File tree

38 files changed

+1244
-84
lines changed

38 files changed

+1244
-84
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ public function execute()
8989
['fileId' => 'image']
9090
);
9191
$uploader->setAllowedExtensions($this->getAllowedExtensions());
92-
93-
if (!$uploader->checkMimeType($this->getAllowedMimeTypes())) {
94-
throw new LocalizedException(__('Disallowed File Type.'));
95-
}
96-
9792
$imageAdapter = $this->adapterFactory->create();
9893
$uploader->addValidateCallback('catalog_product_image', $imageAdapter, 'validateUploadFile');
9994
$uploader->setAllowRenameFiles(true);
@@ -133,14 +128,4 @@ private function getAllowedExtensions()
133128
{
134129
return array_keys($this->allowedMimeTypes);
135130
}
136-
137-
/**
138-
* Get the set of allowed mime types.
139-
*
140-
* @return array
141-
*/
142-
private function getAllowedMimeTypes()
143-
{
144-
return array_values($this->allowedMimeTypes);
145-
}
146131
}

app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickOnAdvancedInventoryLinkActionGroup.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@
1818
<click selector="{{AdminProductFormSection.advancedInventoryLink}}" stepKey="clickOnAdvancedInventoryLink"/>
1919
<waitForPageLoad stepKey="waitForAdvancedInventoryPageToLoad"/>
2020
</actionGroup>
21+
22+
<!-- ActionGroup click on Advanced Inventory Button in product form;
23+
You must already be on the product form page -->
24+
<actionGroup name="AdminClickOnAdvancedInventoryButtonActionGroup">
25+
<annotations>
26+
<description>Clicks on the 'Advanced Inventory' link on the Admin Product creation/edit page.</description>
27+
</annotations>
28+
29+
<click selector="{{AdminProductFormSection.advancedInventoryButton}}" stepKey="clickOnAdvancedInventoryLink"/>
30+
<waitForPageLoad stepKey="waitForAdvancedInventoryPageToLoad"/>
31+
</actionGroup>
2132
</actionGroups>

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']" timeout="30"/>
3939
<element name="unselectCategories" type="button" selector="//span[@class='admin__action-multiselect-crumb']/span[contains(.,'{{category}}')]/../button[@data-action='remove-selected-item']" parameterized="true" timeout="30"/>
4040
<element name="productQuantity" type="input" selector=".admin__field[data-index=qty] input"/>
41-
<element name="advancedInventoryLink" type="button" selector="//button[contains(@data-index, 'advanced_inventory_button')]" timeout="30"/>
41+
<element name="advancedInventoryLink" type="button" selector="button[data-index='advanced_inventory_button'].action-additional" timeout="30"/>
4242
<element name="productStockStatus" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]']" timeout="30"/>
4343
<element name="productStockStatusDisabled" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]'][disabled=true]"/>
4444
<element name="stockStatus" type="select" selector="[data-index='product-details'] select[name='product[quantity_and_stock_status][is_in_stock]']"/>

app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminProductFormSection">
12-
<element name="advancedInventoryLink" type="button" selector="button[data-index='advanced_inventory_button']" timeout="30"/>
12+
<element name="advancedInventoryLink" type="button" selector="button[data-index='advanced_inventory_button'].action-additional" timeout="30"/>
13+
<element name="advancedInventoryButton" type="button" selector="button[data-index='advanced_inventory_button'].action-basic" timeout="30"/>
1314
</section>
1415
</sections>

app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getData(string $blockIdentifier): array
5656
);
5757
}
5858

59-
$renderedContent = $this->widgetFilter->filter($block->getContent());
59+
$renderedContent = $this->widgetFilter->filterDirective($block->getContent());
6060

6161
$blockData = [
6262
BlockInterface::BLOCK_ID => $block->getId(),

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerCreateNewOrderSection.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<element name="updateChangesBtn" type="button" selector=".order-sidebar .actions .action-default.scalable" timeout="30"/>
1313
<element name="productName" type="text" selector="#order-items_grid span[id*=order_item]"/>
1414
<element name="productPrice" type="text" selector=".even td[class=col-price] span[class=price]"/>
15-
<element name="productQty" type="input" selector="td[class=col-qty] input"/>
15+
<element name="productQty" type="input" selector="td[class=col-qty] .input-text.item-qty.admin__control-text"/>
1616
<element name="gridCell" type="text" selector="//div[contains(@id, 'order-items_grid')]//tbody[{{row}}]//td[count(//table[contains(@class, 'order-tables')]//th[contains(., '{{column}}')]/preceding-sibling::th) +1 ]" parameterized="true" timeout="30"/>
1717
</section>
1818
</sections>

app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public function execute(AddressInterface $address): array
105105
foreach ($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES] as $attribute) {
106106
$isArray = false;
107107
if (is_array($attribute['value'])) {
108+
// @ignoreCoverageStart
108109
$isArray = true;
109110
foreach ($attribute['value'] as $attributeValue) {
110111
if (is_array($attributeValue)) {
@@ -116,6 +117,7 @@ public function execute(AddressInterface $address): array
116117
$customAttributes[$attribute['attribute_code']] = implode(',', $attribute['value']);
117118
continue;
118119
}
120+
// @ignoreCoverageEnd
119121
}
120122
if ($isArray) {
121123
continue;

app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ public function __construct(
3939
*
4040
* @param CartInterface $cart
4141
* @param AddressInterface $billingAddress
42-
* @param bool $useForShipping
42+
* @param bool $sameAsShipping
4343
* @throws GraphQlInputException
4444
* @throws GraphQlNoSuchEntityException
4545
*/
4646
public function execute(
4747
CartInterface $cart,
4848
AddressInterface $billingAddress,
49-
bool $useForShipping
49+
bool $sameAsShipping
5050
): void {
5151
try {
52-
$this->billingAddressManagement->assign($cart->getId(), $billingAddress, $useForShipping);
52+
$this->billingAddressManagement->assign($cart->getId(), $billingAddress, $sameAsShipping);
5353
} catch (NoSuchEntityException $e) {
5454
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
5555
} catch (InputException $e) {

app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,25 @@ public function execute(QuoteAddress $address): array
6161
return $addressData;
6262
}
6363

64-
$addressItemsData = [];
6564
foreach ($address->getAllItems() as $addressItem) {
6665
if ($addressItem instanceof \Magento\Quote\Model\Quote\Item) {
6766
$itemId = $addressItem->getItemId();
6867
} else {
6968
$itemId = $addressItem->getQuoteItemId();
7069
}
71-
72-
$addressItemsData[] = [
70+
$productData = $addressItem->getProduct()->getData();
71+
$productData['model'] = $addressItem->getProduct();
72+
$addressData['cart_items'][] = [
7373
'cart_item_id' => $itemId,
7474
'quantity' => $addressItem->getQty()
7575
];
76+
$addressData['cart_items_v2'][] = [
77+
'id' => $itemId,
78+
'quantity' => $addressItem->getQty(),
79+
'product' => $productData,
80+
'model' => $addressItem,
81+
];
7682
}
77-
$addressData['cart_items'] = $addressItemsData;
78-
7983
return $addressData;
8084
}
8185
}

app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
6565
{
6666
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
6767
$addressInput = $billingAddressInput['address'] ?? null;
68-
$useForShipping = isset($billingAddressInput['use_for_shipping'])
68+
// Need to keep this for BC of `use_for_shipping` field
69+
$sameAsShipping = isset($billingAddressInput['use_for_shipping'])
6970
? (bool)$billingAddressInput['use_for_shipping'] : false;
71+
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
72+
? (bool)$billingAddressInput['same_as_shipping'] : $sameAsShipping;
7073

7174
if (null === $customerAddressId && null === $addressInput) {
7275
throw new GraphQlInputException(
@@ -81,15 +84,15 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
8184
}
8285

8386
$addresses = $cart->getAllShippingAddresses();
84-
if ($useForShipping && count($addresses) > 1) {
87+
if ($sameAsShipping && count($addresses) > 1) {
8588
throw new GraphQlInputException(
86-
__('Using the "use_for_shipping" option with multishipping is not possible.')
89+
__('Using the "same_as_shipping" option with multishipping is not possible.')
8790
);
8891
}
8992

9093
$billingAddress = $this->createBillingAddress($context, $customerAddressId, $addressInput);
9194

92-
$this->assignBillingAddressToCart->execute($cart, $billingAddress, $useForShipping);
95+
$this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsShipping);
9396
}
9497

9598
/**

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ input SetBillingAddressOnCartInput {
9696
input BillingAddressInput {
9797
customer_address_id: Int
9898
address: CartAddressInput
99-
use_for_shipping: Boolean
99+
use_for_shipping: Boolean @doc(description: "Deprecated: use `same_as_shipping` field instead")
100+
same_as_shipping: Boolean @doc(description: "Set billing address same as shipping")
100101
}
101102

102103
input CartAddressInput {
@@ -219,18 +220,19 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
219220
type ShippingCartAddress implements CartAddressInterface {
220221
available_shipping_methods: [AvailableShippingMethod] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\AvailableShippingMethods")
221222
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
222-
items_weight: Float
223-
cart_items: [CartItemQuantity]
224223
customer_notes: String
224+
items_weight: Float @deprecated(reason: "This information shoud not be exposed on frontend")
225+
cart_items: [CartItemQuantity] @deprecated(reason: "`cart_items_v2` should be used instead")
226+
cart_items_v2: [CartItemInterface]
225227
}
226228

227229
type BillingCartAddress implements CartAddressInterface {
228230
customer_notes: String @deprecated (reason: "The field is used only in shipping address")
229231
}
230232

231-
type CartItemQuantity {
232-
cart_item_id: Int!
233-
quantity: Float!
233+
type CartItemQuantity @doc(description:"Deprecated: `cart_items` field of `ShippingCartAddress` returns now `CartItemInterface` instead of `CartItemQuantity`") {
234+
cart_item_id: Int! @deprecated(reason: "`cart_items` field of `ShippingCartAddress` returns now `CartItemInterface` instead of `CartItemQuantity`")
235+
quantity: Float! @deprecated(reason: "`cart_items` field of `ShippingCartAddress` returns now `CartItemInterface` instead of `CartItemQuantity`")
234236
}
235237

236238
type CartAddressRegion {

app/code/Magento/Sales/Test/Mftf/Test/CreateOrderFromEditCustomerPageTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
<deleteData createDataKey="createConfigProduct" stepKey="deleteConfigurableProduct"/>
8888
<deleteData createDataKey="createConfigProductAttribute" stepKey="deleteProductAttribute"/>
8989
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
90+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomerIndexPage"/>
91+
<actionGroup ref="clearFiltersAdminDataGrid" stepKey="clearCustomerGridFilter"/>
9092
<actionGroup ref="logout" stepKey="logout"/>
9193
</after>
9294

@@ -98,6 +100,7 @@
98100
<waitForPageLoad stepKey="waitForCustomerEditPageToLoad"/>
99101
<click selector="{{AdminCustomerMainActionsSection.createOrderBtn}}" stepKey="clickOnCreateOrderButton"/>
100102
<waitForPageLoad stepKey="waitForOrderPageToLoad"/>
103+
<conditionalClick selector="{{AdminOrderStoreScopeTreeSection.storeOption(_defaultStore.name)}}" dependentSelector="{{AdminOrderStoreScopeTreeSection.storeOption(_defaultStore.name)}}" visible="true" stepKey="selectStoreViewIfAppears"/>
101104

102105
<!--Add configurable product to order-->
103106
<actionGroup ref="addConfigurableProductToOrderFromAdmin" stepKey="addConfigurableProductToOrder">

app/code/Magento/Widget/Model/Template/FilterEmulate.php

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,44 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Widget\Model\Template;
79

10+
/**
11+
* Class FilterEmulate
12+
*
13+
* @package Magento\Widget\Model\Template
14+
*/
815
class FilterEmulate extends Filter
916
{
1017
/**
1118
* Generate widget with emulation frontend area
1219
*
1320
* @param string[] $construction
14-
* @return string
21+
*
22+
* @return mixed|string
23+
* @throws \Exception
1524
*/
1625
public function widgetDirective($construction)
1726
{
1827
return $this->_appState->emulateAreaCode('frontend', [$this, 'generateWidget'], [$construction]);
1928
}
29+
30+
/**
31+
* Filter the string as template with frontend area emulation
32+
*
33+
* @param string $value
34+
*
35+
* @return string
36+
* @throws \Exception
37+
*/
38+
public function filterDirective($value) : string
39+
{
40+
return $this->_appState->emulateAreaCode(
41+
\Magento\Framework\App\Area::AREA_FRONTEND,
42+
[$this, 'filter'],
43+
[$value]
44+
);
45+
}
2046
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,49 @@ public function testUpdateCustomerAddressWithMissingAttribute()
176176
$this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
177177
}
178178

179+
/**
180+
* Test custom attributes of the customer's address
181+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
182+
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
183+
* @magentoApiDataFixture Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php
184+
*/
185+
public function testUpdateCustomerAddressHasCustomAttributes()
186+
{
187+
$userName = '[email protected]';
188+
$password = 'password';
189+
$addressId = 1;
190+
$attributes = [
191+
[
192+
'attribute_code' => 'custom_attribute1',
193+
'value'=> '[new-value1,new-value2]'
194+
],
195+
[
196+
'attribute_code' => 'custom_attribute2',
197+
'value'=> '"new-value3"'
198+
]
199+
];
200+
$attributesFragment = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', json_encode($attributes));
201+
$mutation
202+
= <<<MUTATION
203+
mutation {
204+
updateCustomerAddress(
205+
id: {$addressId}
206+
input: {
207+
custom_attributes: {$attributesFragment}
208+
}
209+
) {
210+
custom_attributes {
211+
attribute_code
212+
value
213+
}
214+
}
215+
}
216+
MUTATION;
217+
218+
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
219+
$this->assertEquals($attributes, $response['updateCustomerAddress']['custom_attributes']);
220+
}
221+
179222
/**
180223
* Verify the fields for Customer address
181224
*

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,36 @@ public function testAddSimpleProductToCart()
5050
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
5151

5252
self::assertArrayHasKey('cart', $response['addSimpleProductsToCart']);
53+
self::assertArrayHasKey('shipping_addresses', $response['addSimpleProductsToCart']['cart']);
54+
self::assertEmpty($response['addSimpleProductsToCart']['cart']['shipping_addresses']);
5355
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
5456
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
57+
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
58+
59+
self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
60+
$price = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price'];
61+
self::assertArrayHasKey('value', $price);
62+
self::assertEquals(10, $price['value']);
63+
self::assertArrayHasKey('currency', $price);
64+
self::assertEquals('USD', $price['currency']);
65+
66+
self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
67+
$rowTotal = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total'];
68+
self::assertArrayHasKey('value', $rowTotal);
69+
self::assertEquals(20, $rowTotal['value']);
70+
self::assertArrayHasKey('currency', $rowTotal);
71+
self::assertEquals('USD', $rowTotal['currency']);
72+
73+
self::assertArrayHasKey(
74+
'row_total_including_tax',
75+
$response['addSimpleProductsToCart']['cart']['items'][0]['prices']
76+
);
77+
$rowTotalIncludingTax =
78+
$response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax'];
79+
self::assertArrayHasKey('value', $rowTotalIncludingTax);
80+
self::assertEquals(20, $rowTotalIncludingTax['value']);
81+
self::assertArrayHasKey('currency', $rowTotalIncludingTax);
82+
self::assertEquals('USD', $rowTotalIncludingTax['currency']);
5583
}
5684

5785
/**
@@ -262,6 +290,34 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
262290
product {
263291
sku
264292
}
293+
prices {
294+
price {
295+
value
296+
currency
297+
}
298+
row_total {
299+
value
300+
currency
301+
}
302+
row_total_including_tax {
303+
value
304+
currency
305+
}
306+
}
307+
}
308+
shipping_addresses {
309+
firstname
310+
lastname
311+
company
312+
street
313+
city
314+
postcode
315+
telephone
316+
country {
317+
code
318+
label
319+
}
320+
__typename
265321
}
266322
}
267323
}

0 commit comments

Comments
 (0)