Skip to content

Commit 5c7e13f

Browse files
committed
Merge branch '2.3-develop' of github.com:magento-mpi/magento2ce into MAGETWO-99035
2 parents 0c651cc + 48d8d43 commit 5c7e13f

File tree

13 files changed

+265
-115
lines changed

13 files changed

+265
-115
lines changed

app/code/Magento/Bundle/Test/Mftf/Test/AdminDeleteBundleDynamicProductTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<severity value="CRITICAL"/>
1717
<testCaseId value="MC-11016"/>
1818
<group value="mtf_migrated"/>
19+
<skip>
20+
<issueId value="MC-16393"/>
21+
</skip>
1922
</annotations>
2023
<before>
2124
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@
6262
<seeElement selector="{{StorefrontCategoryProductSection.ProductAddToCartByName(product.name)}}" stepKey="AssertAddToCart" />
6363
</actionGroup>
6464

65+
<actionGroup name="StorefrontCheckAddToCartButtonAbsence">
66+
<arguments>
67+
<argument name="product" defaultValue="_defaultProduct"/>
68+
</arguments>
69+
<moveMouseOver selector="{{StorefrontCategoryProductSection.ProductInfoByName(product.name)}}" stepKey="moveMouseOverProduct" />
70+
<dontSeeElement selector="{{StorefrontCategoryProductSection.ProductAddToCartByName(product.name)}}" stepKey="checkAddToCartButtonAbsence"/>
71+
</actionGroup>
6572
<actionGroup name="StorefrontSwitchCategoryViewToListMode">
6673
<click selector="{{StorefrontCategoryMainSection.modeListButton}}" stepKey="switchCategoryViewToListMode"/>
6774
<waitForElement selector="{{StorefrontCategoryMainSection.CategoryTitle}}" time="30" stepKey="waitForCategoryReload"/>

app/code/Magento/Cms/Controller/Adminhtml/Page/Index.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
use Magento\Framework\App\Action\HttpGetActionInterface;
99
use Magento\Backend\App\Action\Context;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\App\Request\DataPersistorInterface;
1012
use Magento\Framework\View\Result\PageFactory;
1113

1214
/**
@@ -26,16 +28,24 @@ class Index extends \Magento\Backend\App\Action implements HttpGetActionInterfac
2628
*/
2729
protected $resultPageFactory;
2830

31+
/**
32+
* @var DataPersistorInterface
33+
*/
34+
private $dataPersistor;
35+
2936
/**
3037
* @param Context $context
3138
* @param PageFactory $resultPageFactory
39+
* @param DataPersistorInterface $dataPersistor
3240
*/
3341
public function __construct(
3442
Context $context,
35-
PageFactory $resultPageFactory
43+
PageFactory $resultPageFactory,
44+
DataPersistorInterface $dataPersistor = null
3645
) {
3746
parent::__construct($context);
3847
$this->resultPageFactory = $resultPageFactory;
48+
$this->dataPersistor = $dataPersistor ?: ObjectManager::getInstance()->get(DataPersistorInterface::class);
3949
}
4050

4151
/**
@@ -52,8 +62,7 @@ public function execute()
5262
$resultPage->addBreadcrumb(__('Manage Pages'), __('Manage Pages'));
5363
$resultPage->getConfig()->getTitle()->prepend(__('Pages'));
5464

55-
$dataPersistor = $this->_objectManager->get(\Magento\Framework\App\Request\DataPersistorInterface::class);
56-
$dataPersistor->clear('cms_page');
65+
$this->dataPersistor->clear('cms_page');
5766

5867
return $resultPage;
5968
}

app/code/Magento/Search/Test/Mftf/Test/StorefrontVerifySearchSuggestionByProductDescriptionTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<severity value="CRITICAL"/>
1717
<testCaseId value="MC-14765"/>
1818
<group value="mtf_migrated"/>
19+
<skip>
20+
<issueId value="MC-17012"/>
21+
</skip>
1922
</annotations>
2023

2124
<before>

app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ define([
12541254
dataMergeStrategy: this.options.gallerySwitchStrategy
12551255
});
12561256
}
1257-
1257+
gallery.first();
12581258
} else if (justAnImage && justAnImage.img) {
12591259
context.find('.product-image-photo').attr('src', justAnImage.img);
12601260
}

app/code/Magento/Translation/Model/Js/PreProcessor.php

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

810
use Magento\Framework\App\AreaList;
@@ -92,6 +94,6 @@ public function translate($content)
9294
*/
9395
protected function replaceCallback($matches)
9496
{
95-
return '"' . __($matches[1]) . '"';
97+
return '\'' . __($matches['translate']) . '\'';
9698
}
9799
}

app/code/Magento/Translation/Test/Unit/Model/Js/PreProcessorTest.php

Lines changed: 0 additions & 85 deletions
This file was deleted.

app/code/Magento/Translation/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
<argument name="patterns" xsi:type="array">
6666
<item name="i18n_translation" xsi:type="string"><![CDATA[~i18n\:\s*(["'])(.*?)(?<!\\)\1~]]></item>
6767
<item name="translate_wrapping" xsi:type="string"><![CDATA[~translate\=("')([^\'].*?)\'\"~]]></item>
68-
<item name="mage_translation_widget" xsi:type="string"><![CDATA[~(?:\$|jQuery)\.mage\.__\((?s)[^'"]*?(['"])(.+?)(?<!\\)\1(?s).*?\)~]]></item>
69-
<item name="mage_translation_static" xsi:type="string"><![CDATA[~\$t\((?s)[^'"]*?(["'])(.+?)\1(?s).*?\)~]]></item>
68+
<item name="mage_translation_widget" xsi:type="string"><![CDATA[~(?s)(?:\$|jQuery)\.mage\.__\(\s*(['"])(?<translate>.+?)(?<!\\)\1\s*(*SKIP)\)\s*(?s)~]]></item>
69+
<item name="mage_translation_static" xsi:type="string"><![CDATA[~(?s)\$t\(\s*(['"])(?<translate>.+?)(?<!\\)\1\s*(*SKIP)\)(?s)~]]></item>
7070
<item name="translate_args" xsi:type="string"><![CDATA[~translate args\=("|'|"')([^\'].*?)('"|'|")~]]></item>
7171
</argument>
7272
</arguments>
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
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\Translation\Model\Js;
9+
10+
use Magento\TestFramework\Helper\Bootstrap;
11+
use Magento\Framework\View\FileSystem;
12+
use Magento\TestFramework\Helper\CacheCleaner;
13+
use Magento\Framework\Translate;
14+
use Magento\Framework\App\AreaList;
15+
use Magento\Framework\Phrase;
16+
use Magento\Framework\Phrase\RendererInterface;
17+
18+
/**
19+
* Class for testing translation.
20+
*/
21+
class PreProcessorTest extends \PHPUnit\Framework\TestCase
22+
{
23+
/**
24+
* @var PreProcessor
25+
*/
26+
private $model;
27+
28+
/**
29+
* @var RendererInterface
30+
*/
31+
private $origRenderer;
32+
33+
/**
34+
* Set up.
35+
*/
36+
protected function setUp()
37+
{
38+
$viewFileSystem = $this->createPartialMock(FileSystem::class, ['getLocaleFileName']);
39+
$viewFileSystem->expects($this->any())->method('getLocaleFileName')
40+
->willReturn(
41+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
42+
dirname(__DIR__) . '/_files/Magento/Store/i18n/en_AU.csv'
43+
);
44+
45+
$objectManager = Bootstrap::getObjectManager();
46+
$objectManager->addSharedInstance($viewFileSystem, FileSystem::class);
47+
$translator = $objectManager->create(Translate::class);
48+
$objectManager->addSharedInstance($translator, Translate::class);
49+
$areaList = $this->getMockBuilder(AreaList::class)->disableOriginalConstructor()->getMock();
50+
$this->origRenderer = Phrase::getRenderer();
51+
Phrase::setRenderer(
52+
$objectManager->get(RendererInterface::class)
53+
);
54+
55+
$this->model = $objectManager->create(
56+
PreProcessor::class,
57+
[
58+
'translate' => $translator,
59+
'areaList' => $areaList
60+
]
61+
);
62+
63+
$translator->setLocale('en_AU');
64+
$translator->loadData();
65+
}
66+
67+
/**
68+
* Tear down.
69+
*/
70+
protected function tearDown()
71+
{
72+
Phrase::setRenderer($this->origRenderer);
73+
}
74+
75+
/**
76+
* Test for backend translation strategy.
77+
*
78+
* @param string $content
79+
* @param string $translation
80+
* @return void
81+
* @dataProvider contentForTranslateDataProvider
82+
*/
83+
public function testProcess(string $content, string $translation)
84+
{
85+
CacheCleaner::cleanAll();
86+
$this->assertEquals($translation, $this->model->translate($content));
87+
}
88+
89+
/**
90+
* Data provider for translation.
91+
*
92+
* @return array
93+
*/
94+
public function contentForTranslateDataProvider()
95+
{
96+
return [
97+
'i18n_js_file_error' => [
98+
'setTranslateProp = function (el, original) {
99+
var location = $(el).prop(\'tagName\').toLowerCase(),
100+
translated = $.mage.__(original),
101+
translationData = {
102+
shown: translated,
103+
translated: translated,
104+
original: original
105+
},
106+
translateAttr = composeTranslateAttr(translationData, location);
107+
108+
$(el).attr(\'data-translate\', translateAttr);
109+
110+
setText(el, translationData.shown);
111+
},',
112+
'setTranslateProp = function (el, original) {
113+
var location = $(el).prop(\'tagName\').toLowerCase(),
114+
translated = $.mage.__(original),
115+
translationData = {
116+
shown: translated,
117+
translated: translated,
118+
original: original
119+
},
120+
translateAttr = composeTranslateAttr(translationData, location);
121+
122+
$(el).attr(\'data-translate\', translateAttr);
123+
124+
setText(el, translationData.shown);
125+
},'
126+
],
127+
'checkTranslationWithWhiteSpaces' => [
128+
<<<i18n
129+
title: $.mage.__(
130+
'Original value for Magento_Store module'
131+
),
132+
title: \$t(
133+
'Original value for Magento_Store module'
134+
);
135+
title: jQuery.mage.__(
136+
'Original value for Magento_Store module'
137+
);
138+
i18n
139+
,
140+
<<<i18n
141+
title: 'Translated value for Magento_Store module in en_AU',
142+
title: 'Translated value for Magento_Store module in en_AU';
143+
title: 'Translated value for Magento_Store module in en_AU';
144+
i18n
145+
],
146+
'checkTranslationWithReplace' => [
147+
<<<i18n
148+
$.mage.__('The maximum you may purchase is %1.').replace('%1', params.maxAllowed);
149+
\$t('The maximum you may purchase is %1.').replace('%1', params.maxAllowed);
150+
i18n
151+
,
152+
<<<i18n
153+
'The maximum you may purchase is %1.'.replace('%1', params.maxAllowed);
154+
'The maximum you may purchase is %1.'.replace('%1', params.maxAllowed);
155+
i18n
156+
],
157+
'checkAvoidingMatchingWithJsInString' => [
158+
<<<i18n
159+
\$t('Payment ' + this.getTitle() + ' can\'t be initialized')
160+
\$t(
161+
'Set unique country-state combinations within the same fixed product tax. ' +
162+
'Verify the combinations and try again.'
163+
)
164+
i18n
165+
,
166+
<<<i18n
167+
\$t('Payment ' + this.getTitle() + ' can\'t be initialized')
168+
\$t(
169+
'Set unique country-state combinations within the same fixed product tax. ' +
170+
'Verify the combinations and try again.'
171+
)
172+
i18n
173+
],
174+
'checkAvoidMatchingPhtml' => [
175+
<<<i18n
176+
globalMessageList.addErrorMessage({
177+
message: \$t(<?= /* @noEscape */ json_encode(\$params['error_msg'])?>)
178+
});
179+
i18n
180+
,
181+
<<<i18n
182+
globalMessageList.addErrorMessage({
183+
message: \$t(<?= /* @noEscape */ json_encode(\$params['error_msg'])?>)
184+
});
185+
i18n
186+
]
187+
];
188+
}
189+
}

0 commit comments

Comments
 (0)