Skip to content

Commit 3ddbf83

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into 2.3-tests-pr
2 parents 7ad3a8c + fb58417 commit 3ddbf83

File tree

112 files changed

+8440
-746
lines changed

Some content is hidden

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

112 files changed

+8440
-746
lines changed

app/code/Magento/Braintree/Model/LocaleResolver.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Framework\Locale\ResolverInterface;
99
use Magento\Braintree\Gateway\Config\PayPal\Config;
1010

11+
/**
12+
* Resolves locale for PayPal Express.
13+
*/
1114
class LocaleResolver implements ResolverInterface
1215
{
1316
/**
@@ -20,6 +23,17 @@ class LocaleResolver implements ResolverInterface
2023
*/
2124
private $config;
2225

26+
/**
27+
* Mapping Magento locales on PayPal locales.
28+
*
29+
* @var array
30+
*/
31+
private $localeMap = [
32+
'zh_Hans_CN' => 'zh_CN',
33+
'zh_Hant_HK' => 'zh_HK',
34+
'zh_Hant_TW' => 'zh_TW'
35+
];
36+
2337
/**
2438
* @param ResolverInterface $resolver
2539
* @param Config $config
@@ -66,10 +80,11 @@ public function setLocale($locale = null)
6680
* Gets store's locale or the `en_US` locale if store's locale does not supported by PayPal.
6781
*
6882
* @return string
83+
* @see https://braintree.github.io/braintree-web/current/PayPalCheckout.html#createPayment
6984
*/
7085
public function getLocale()
7186
{
72-
$locale = $this->resolver->getLocale();
87+
$locale = $this->localeMap[$this->resolver->getLocale()] ?? $this->resolver->getLocale();
7388
$allowedLocales = $this->config->getValue('supported_locales');
7489

7590
return strpos($allowedLocales, $locale) !== false ? $locale : 'en_US';

app/code/Magento/Braintree/Test/Unit/Model/LocaleResolverTest.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,35 @@ public function testSetLocale()
9898
/**
9999
* Test getLocale method
100100
*
101-
* @return void
101+
* @param string $locale
102+
* @param string $expectedLocale
103+
* @dataProvider getLocaleDataProvider
102104
*/
103-
public function testGetLocale()
105+
public function testGetLocale(string $locale, string $expectedLocale)
104106
{
105-
$locale = 'en_TEST';
106-
$allowedLocales = 'en_US,en_GB,en_AU,da_DK,fr_FR,fr_CA,de_DE,zh_HK,it_IT,nl_NL';
107-
$this->resolverMock->expects($this->once())->method('getLocale')->willReturn($locale);
108-
$this->configMock->expects($this->once())->method('getValue')->with('supported_locales')
107+
$allowedLocales = 'en_US,en_GB,en_AU,da_DK,fr_FR,fr_CA,de_DE,zh_HK,it_IT,zh_CN,zh_TW,nl_NL';
108+
$this->resolverMock->method('getLocale')
109+
->willReturn($locale);
110+
$this->configMock->method('getValue')
111+
->with('supported_locales')
109112
->willReturn($allowedLocales);
110-
111-
$expected = 'en_US';
112113
$actual = $this->localeResolver->getLocale();
113-
self::assertEquals($expected, $actual);
114+
115+
self::assertEquals($expectedLocale, $actual);
116+
}
117+
118+
/**
119+
* @return array
120+
*/
121+
public function getLocaleDataProvider(): array
122+
{
123+
return [
124+
['locale' => 'zh_Hans_CN', 'expectedLocale' => 'zh_CN'],
125+
['locale' => 'zh_Hant_HK', 'expectedLocale' => 'zh_HK'],
126+
['locale' => 'zh_Hant_TW', 'expectedLocale' => 'zh_TW'],
127+
['locale' => 'fr_FR', 'expectedLocale' => 'fr_FR'],
128+
['locale' => 'unknown', 'expectedLocale' => 'en_US'],
129+
];
114130
}
115131

116132
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<!--Category Selection-->
9393
<element name="categoryByName" type="multiselect" selector="//div[@data-index='category_ids']//span[contains(text(), '{{category}}')]" parameterized="true"/>
9494
<element name="searchForCategory" type="input" selector="div.action-menu._active > div.admin__action-multiselect-search-wrap input" timeout="30"/>
95-
<element name="selectCategory" type="multiselect" selector="//div[@class='action-menu _active']//label[@class='admin__action-multiselect-label']"/>
95+
<element name="selectCategory" type="multiselect" selector="//div[@class='action-menu _active']//label[@class='admin__action-multiselect-label']" timeout="30"/>
9696
<element name="categoriesLabel" type="text" selector="//div[@class='action-menu _active']//button[@data-action='close-advanced-select']"/>
9797
<element name="userDefinedQuantity" type="checkbox" selector="[name='bundle_options[bundle_options][{{option}}][bundle_selections][{{product}}][selection_can_change_qty]'][type='checkbox']" parameterized="true"/>
9898
</section>

app/code/Magento/Bundle/view/adminhtml/templates/sales/order/view/items/renderer.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
</td>
155155
<td class="col-discont">
156156
<?php if ($block->canShowPriceInfo($_item)) : ?>
157-
<?= $block->escapeHtml($block->displayPriceAttribute('discount_amount')) ?>
157+
<?= /* @noEscape */ $block->displayPriceAttribute('discount_amount') ?>
158158
<?php else : ?>
159159
&nbsp;
160160
<?php endif; ?>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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\Catalog\Model\Category;
9+
10+
use Magento\Catalog\Api\CategoryRepositoryInterface;
11+
use Magento\Catalog\Model\Category;
12+
use Magento\Store\Api\GroupRepositoryInterface;
13+
14+
/**
15+
* Fetcher for associated with store group categories.
16+
*/
17+
class StoreCategories
18+
{
19+
/**
20+
* @var CategoryRepositoryInterface
21+
*/
22+
private $categoryRepository;
23+
24+
/**
25+
* @var GroupRepositoryInterface
26+
*/
27+
private $groupRepository;
28+
29+
/**
30+
* @param CategoryRepositoryInterface $categoryRepository
31+
* @param GroupRepositoryInterface $groupRepository
32+
*/
33+
public function __construct(
34+
CategoryRepositoryInterface $categoryRepository,
35+
GroupRepositoryInterface $groupRepository
36+
) {
37+
$this->categoryRepository = $categoryRepository;
38+
$this->groupRepository = $groupRepository;
39+
}
40+
41+
/**
42+
* Get all category ids for store.
43+
*
44+
* @param int|null $storeGroupId
45+
* @return int[]
46+
* @throws \Magento\Framework\Exception\NoSuchEntityException
47+
*/
48+
public function getCategoryIds(?int $storeGroupId = null): array
49+
{
50+
$rootCategoryId = $storeGroupId
51+
? $this->groupRepository->get($storeGroupId)->getRootCategoryId()
52+
: Category::TREE_ROOT_ID;
53+
/** @var Category $rootCategory */
54+
$rootCategory = $this->categoryRepository->get($rootCategoryId);
55+
$categoriesIds = array_map(
56+
function ($value) {
57+
return (int) $value;
58+
},
59+
(array) $rootCategory->getAllChildren(true)
60+
);
61+
62+
return $categoriesIds;
63+
}
64+
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +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="AdminProductCustomizableOptionsSection">
12-
<element name="checkIfCustomizableOptionsTabOpen" type="text" selector="//span[text()='Customizable Options']/parent::strong/parent::*[@data-state-collapsible='closed']"/>
12+
<element name="checkIfCustomizableOptionsTabOpen" type="text" selector="//span[text()='Customizable Options']/parent::strong/parent::*[@data-state-collapsible='closed']" timeout="30"/>
1313
<element name="customizableOptions" type="text" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Customizable Options']"/>
1414
<element name="useDefaultOptionTitle" type="text" selector="[data-index='options'] tr.data-row [data-index='title'] [name^='options_use_default']"/>
1515
<element name="useDefaultOptionTitleByIndex" type="text" selector="[data-index='options'] [data-index='values'] tr[data-repeat-index='{{var1}}'] [name^='options_use_default']" parameterized="true"/>
@@ -23,8 +23,8 @@
2323
<element name="customOption" type="block" selector="[data-index='options'] tbody tr.data-row"/>
2424
<element name="customOptionButtonDelete" type="button" selector="[data-index='options'] [data-index='delete_button']"/>
2525

26-
<element name="optionTypeDropDown" type="select" selector="//table[@data-index='options']//tr[{{index}}]//div[@data-index='type']//div[contains(@class, 'action-select-wrap')]" parameterized="true" />
27-
<element name="optionTypeItem" type="select" selector="//table[@data-index='options']//tr[{{index}}]//div[@data-index='type']//*[contains(@class, 'action-menu-item')]//*[contains(., '{{optionValue}}')]" parameterized="true" />
26+
<element name="optionTypeDropDown" type="select" selector="//table[@data-index='options']//tr[{{index}}]//div[@data-index='type']//div[contains(@class, 'action-select-wrap')]" parameterized="true" timeout="30"/>
27+
<element name="optionTypeItem" type="select" selector="//table[@data-index='options']//tr[{{index}}]//div[@data-index='type']//*[contains(@class, 'action-menu-item')]//*[contains(., '{{optionValue}}')]" parameterized="true" timeout="30"/>
2828
<element name="checkSelect" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//span[text()='Option Type']/parent::label/parent::div/parent::div//div[@data-role='selected-option']" parameterized="true"/>
2929
<element name="checkOptionType" type="select" selector="//span[text()='{{optionTitle}}']/parent::div/parent::div/parent::div//parent::label/parent::div/parent::div//li[@class='admin__action-multiselect-menu-inner-item']//label[text()='{{optionType}}']" parameterized="true"/>
3030
<element name="checkDropDown" type="select" selector="//span[text()='{{var1}}']/parent::div/parent::div/parent::div//parent::label/parent::div/parent::div//li[@class='admin__action-multiselect-menu-inner-item']//label[text()='Drop-down']" parameterized="true"/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<element name="qtyIncrementsUseConfigSettings" type="checkbox" selector="//input[@name='product[stock_data][use_config_qty_increments]']"/>
1919
<element name="doneButton" type="button" selector="//aside[contains(@class,'product_form_product_form_advanced_inventory_modal')]//button[contains(@data-role,'action')]" timeout="5"/>
2020
<element name="useConfigSettings" type="checkbox" selector="//input[@name='product[stock_data][use_config_manage_stock]']"/>
21-
<element name="manageStock" type="select" selector="//*[@name='product[stock_data][manage_stock]']"/>
21+
<element name="manageStock" type="select" selector="//*[@name='product[stock_data][manage_stock]']" timeout="30"/>
2222
<element name="advancedInventoryCloseButton" type="button" selector=".product_form_product_form_advanced_inventory_modal button.action-close" timeout="30"/>
2323
<element name="miniQtyConfigSetting" type="checkbox" selector="//*[@name='product[stock_data][use_config_min_sale_qty]']"/>
2424
<element name="miniQtyAllowedInCart" type="input" selector="//*[@name='product[stock_data][min_sale_qty]']"/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
<element name="productTierPriceFixedPriceInput" type="input" selector="[name='product[tier_price][{{var1}}][price]']" parameterized="true"/>
2222
<element name="productTierPricePercentageValuePriceInput" type="input" selector="[name='product[tier_price][{{var1}}][percentage_value]']" parameterized="true"/>
2323
<element name="specialPrice" type="input" selector="input[name='product[special_price]']"/>
24-
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary" timeout="5"/>
24+
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary" timeout="30"/>
2525
<element name="msrp" type="input" selector="//input[@name='product[msrp]']" timeout="30"/>
2626
<element name="msrpType" type="select" selector="//select[@name='product[msrp_display_actual_price_type]']" timeout="30"/>
27-
<element name="save" type="button" selector="#save-button"/>
27+
<element name="save" type="button" selector="#save-button" timeout="30"/>
2828
</section>
2929
</sections>

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
<element name="productTaxClassUseDefault" type="checkbox" selector="input[name='use_default[tax_class_id]']"/>
3535
<element name="advancedPricingLink" type="button" selector="button[data-index='advanced_pricing_button']" timeout="30"/>
3636
<element name="currentCategory" type="text" selector=".admin__action-multiselect-crumb > span"/>
37-
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']"/>
37+
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']" timeout="30"/>
3838
<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"/>
3939
<element name="productQuantity" type="input" selector=".admin__field[data-index=qty] input"/>
4040
<element name="advancedInventoryLink" type="button" selector="//button[contains(@data-index, 'advanced_inventory_button')]" timeout="30"/>
41-
<element name="productStockStatus" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]']"/>
41+
<element name="productStockStatus" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]']" timeout="30"/>
4242
<element name="productStockStatusDisabled" type="select" selector="select[name='product[quantity_and_stock_status][is_in_stock]'][disabled=true]"/>
4343
<element name="stockStatus" type="select" selector="[data-index='product-details'] select[name='product[quantity_and_stock_status][is_in_stock]']"/>
4444
<element name="productWeight" type="input" selector=".admin__field[data-index=weight] input"/>
@@ -48,7 +48,7 @@
4848
<element name="priceFieldError" type="text" selector="//input[@name='product[price]']/parent::div/parent::div/label[@class='admin__field-error']"/>
4949
<element name="addAttributeBtn" type="button" selector="#addAttribute"/>
5050
<element name="createNewAttributeBtn" type="button" selector="button[data-index='add_new_attribute_button']"/>
51-
<element name="save" type="button" selector="#save-button"/>
51+
<element name="save" type="button" selector="#save-button" timeout="30"/>
5252
<element name="saveNewAttribute" type="button" selector="//aside[contains(@class, 'create_new_attribute_modal')]//button[@id='save']"/>
5353
<element name="successMessage" type="text" selector="#messages"/>
5454
<element name="attributeTab" type="button" selector="//strong[contains(@class, 'admin__collapsible-title')]/span[text()='Attributes']"/>
@@ -67,7 +67,7 @@
6767
<element name="attributeFieldError" type="text" selector="//*[@class='admin__field _required _error']/..//label[contains(.,'This is a required field.')]"/>
6868
<element name="customSelectField" type="select" selector="//select[@name='product[{{var}}]']" parameterized="true"/>
6969
<element name="searchCategory" type="input" selector="//*[@data-index='category_ids']//input[contains(@class, 'multiselect-search')]"/>
70-
<element name="selectCategory" type="input" selector="//*[@data-index='category_ids']//label[contains(., '{{categoryName}}')]" parameterized="true"/>
70+
<element name="selectCategory" type="input" selector="//*[@data-index='category_ids']//label[contains(., '{{categoryName}}')]" parameterized="true" timeout="30"/>
7171
<element name="done" type="button" selector="//*[@data-index='category_ids']//button[@data-action='close-advanced-select']" timeout="30"/>
7272
<element name="selectMultipleCategories" type="input" selector="//*[@data-index='container_category_ids']//*[contains(@class, '_selected')]"/>
7373
<element name="countryOfManufacture" type="select" selector="select[name='product[country_of_manufacture]']"/>
@@ -206,7 +206,7 @@
206206
</section>
207207
<section name="AdminProductFormAdvancedPricingSection">
208208
<element name="specialPrice" type="input" selector="input[name='product[special_price]']"/>
209-
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary"/>
209+
<element name="doneButton" type="button" selector=".product_form_product_form_advanced_pricing_modal button.action-primary" timeout="30"/>
210210
<element name="useDefaultPrice" type="checkbox" selector="//input[@name='product[special_price]']/parent::div/following-sibling::div/input[@name='use_default[special_price]']"/>
211211
</section>
212212
<section name="AdminProductAttributeSection">

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminProductGridActionSection">
1212
<element name="addProductBtn" type="button" selector="#add_new_product-button" timeout="30"/>
13-
<element name="addProductToggle" type="button" selector=".action-toggle.primary.add"/>
13+
<element name="addProductToggle" type="button" selector=".action-toggle.primary.add" timeout="30"/>
1414
<element name="addSimpleProduct" type="button" selector=".item[data-ui-id='products-list-add-new-product-button-item-simple']" timeout="30"/>
1515
<element name="addGroupedProduct" type="button" selector=".item[data-ui-id='products-list-add-new-product-button-item-grouped']" timeout="30"/>
1616
<element name="addVirtualProduct" type="button" selector=".item[data-ui-id='products-list-add-new-product-button-item-virtual']" timeout="30"/>

0 commit comments

Comments
 (0)