Skip to content

Commit 524cb80

Browse files
committed
Merge remote-tracking branch 'origin/2.4.7-beta1-develop' into Sync-2.4.7-beta1-develop
2 parents cfaeeae + c0d47f1 commit 524cb80

File tree

71 files changed

+1208
-452
lines changed

Some content is hidden

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

71 files changed

+1208
-452
lines changed

app/code/Magento/Captcha/Test/Mftf/Test/StorefrontCaptchaOnOnepageCheckoutPyamentTest.xml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<group value="storefront_captcha_enabled"/>
2222
</annotations>
2323
<before>
24+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
2425
<!-- Create Simple Product -->
2526
<createData entity="SimpleProduct2" stepKey="createSimpleProduct">
2627
<field key="price">20</field>
@@ -62,6 +63,7 @@
6263

6364
<!-- Delete customer -->
6465
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
66+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
6567
</after>
6668

6769
<!-- Reindex and flush cache -->

app/code/Magento/Catalog/Controller/Adminhtml/Product/NewAction.php

+21-4
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
* Copyright © Magento, Inc. All rights reserved.
55
* See COPYING.txt for license details.
66
*/
7+
declare(strict_types=1);
8+
79
namespace Magento\Catalog\Controller\Adminhtml\Product;
810

9-
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
10-
use Magento\Backend\App\Action;
1111
use Magento\Catalog\Controller\Adminhtml\Product;
12+
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
1213
use Magento\Framework\App\ObjectManager;
14+
use Magento\Framework\RegexValidator;
1315

1416
class NewAction extends \Magento\Catalog\Controller\Adminhtml\Product implements HttpGetActionInterface
1517
{
1618
/**
1719
* @var Initialization\StockDataFilter
1820
* @deprecated 101.0.0
21+
* @see Initialization\StockDataFilter
1922
*/
2023
protected $stockFilter;
2124

@@ -30,23 +33,32 @@ class NewAction extends \Magento\Catalog\Controller\Adminhtml\Product implements
3033
protected $resultForwardFactory;
3134

3235
/**
33-
* @param Action\Context $context
36+
* @var RegexValidator
37+
*/
38+
private RegexValidator $regexValidator;
39+
40+
/**
41+
* @param Context $context
3442
* @param Builder $productBuilder
3543
* @param Initialization\StockDataFilter $stockFilter
3644
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
3745
* @param \Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
46+
* @param RegexValidator|null $regexValidator
3847
*/
3948
public function __construct(
4049
\Magento\Backend\App\Action\Context $context,
4150
Product\Builder $productBuilder,
4251
Initialization\StockDataFilter $stockFilter,
4352
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
44-
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory
53+
\Magento\Backend\Model\View\Result\ForwardFactory $resultForwardFactory,
54+
RegexValidator $regexValidator = null
4555
) {
4656
$this->stockFilter = $stockFilter;
4757
parent::__construct($context, $productBuilder);
4858
$this->resultPageFactory = $resultPageFactory;
4959
$this->resultForwardFactory = $resultForwardFactory;
60+
$this->regexValidator = $regexValidator
61+
?: ObjectManager::getInstance()->get(RegexValidator::class);
5062
}
5163

5264
/**
@@ -56,6 +68,11 @@ public function __construct(
5668
*/
5769
public function execute()
5870
{
71+
$typeId = $this->getRequest()->getParam('type');
72+
if (!$this->regexValidator->validateParamRegex($typeId)) {
73+
return $this->resultForwardFactory->create()->forward('noroute');
74+
}
75+
5976
if (!$this->getRequest()->getParam('set')) {
6077
return $this->resultForwardFactory->create()->forward('noroute');
6178
}

app/code/Magento/Catalog/Test/Mftf/Test/EndToEndB2CAdminTest.xml

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
<testCaseId value="MAGETWO-87014"/>
1919
<group value="pr_exclude"/>
2020
</annotations>
21+
<before>
22+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 1" stepKey="EnablingGuestCheckoutLogin"/>
23+
</before>
2124
<after>
2225
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutOfAdmin"/>
26+
<magentoCLI command="config:set checkout/options/enable_guest_checkout_login 0" stepKey="DisablingGuestCheckoutLogin"/>
2327
</after>
2428

2529
<!--Login to Admin Area-->
2630
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminArea"/>
27-
2831
<!--Admin creates product-->
2932
<!--Create Simple Product-->
3033
<actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="visitAdminProductPageSimple"/>

app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/NewActionTest.php

100644100755
+77-13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use Magento\Catalog\Controller\Adminhtml\Product\NewAction;
1717
use Magento\Catalog\Model\Product;
1818
use Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest;
19+
use Magento\Framework\RegexValidator;
20+
use Magento\Framework\Validator\Regex;
21+
use Magento\Framework\Validator\RegexFactory;
1922
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
2023
use Magento\Framework\View\Result\PageFactory;
2124
use PHPUnit\Framework\MockObject\MockObject;
@@ -42,6 +45,26 @@ class NewActionTest extends ProductTest
4245
*/
4346
protected $initializationHelper;
4447

48+
/**
49+
* @var RegexValidator|MockObject
50+
*/
51+
private $regexValidator;
52+
53+
/**
54+
* @var RegexFactory
55+
*/
56+
private $regexValidatorFactoryMock;
57+
58+
/**
59+
* @var Regex|MockObject
60+
*/
61+
private $regexValidatorMock;
62+
63+
/**
64+
* @var ForwardFactory&MockObject|MockObject
65+
*/
66+
private $resultForwardFactory;
67+
4568
protected function setUp(): void
4669
{
4770
$this->productBuilder = $this->createPartialMock(
@@ -63,37 +86,78 @@ protected function setUp(): void
6386
->disableOriginalConstructor()
6487
->setMethods(['create'])
6588
->getMock();
66-
$resultPageFactory->expects($this->atLeastOnce())
67-
->method('create')
68-
->willReturn($this->resultPage);
6989

7090
$this->resultForward = $this->getMockBuilder(Forward::class)
7191
->disableOriginalConstructor()
7292
->getMock();
73-
$resultForwardFactory = $this->getMockBuilder(ForwardFactory::class)
93+
$this->resultForwardFactory = $this->getMockBuilder(ForwardFactory::class)
94+
->disableOriginalConstructor()
95+
->onlyMethods(['create'])
96+
->getMock();
97+
98+
$this->regexValidatorFactoryMock = $this->getMockBuilder(RegexFactory::class)
7499
->disableOriginalConstructor()
75100
->setMethods(['create'])
76101
->getMock();
77-
$resultForwardFactory->expects($this->any())
78-
->method('create')
79-
->willReturn($this->resultForward);
102+
$this->regexValidatorMock = $this->createMock(Regex::class);
103+
$this->regexValidatorFactoryMock->method('create')
104+
->willReturn($this->regexValidatorMock);
80105

106+
$this->regexValidator = new regexValidator($this->regexValidatorFactoryMock);
81107
$this->action = (new ObjectManager($this))->getObject(
82108
NewAction::class,
83109
[
84110
'context' => $this->initContext(),
85111
'productBuilder' => $this->productBuilder,
86112
'resultPageFactory' => $resultPageFactory,
87-
'resultForwardFactory' => $resultForwardFactory,
113+
'resultForwardFactory' => $this->resultForwardFactory,
114+
'regexValidator' => $this->regexValidator,
88115
]
89116
);
90117
}
91118

92-
public function testExecute()
119+
/**
120+
* Test execute method input validation.
121+
*
122+
* @param string $value
123+
* @param bool $exceptionThrown
124+
* @dataProvider validationCases
125+
*/
126+
public function testExecute(string $value, bool $exceptionThrown): void
127+
{
128+
if ($exceptionThrown) {
129+
$this->action->getRequest()->expects($this->any())
130+
->method('getParam')
131+
->willReturn($value);
132+
$this->resultForwardFactory->expects($this->any())
133+
->method('create')
134+
->willReturn($this->resultForward);
135+
$this->resultForward->expects($this->once())
136+
->method('forward')
137+
->with('noroute')
138+
->willReturn(true);
139+
$this->assertTrue($this->action->execute());
140+
} else {
141+
$this->action->getRequest()->expects($this->any())->method('getParam')->willReturn($value);
142+
$this->regexValidatorMock->expects($this->any())
143+
->method('isValid')
144+
->with($value)
145+
->willReturn(true);
146+
147+
$this->assertEquals(true, $this->regexValidator->validateParamRegex($value));
148+
}
149+
}
150+
151+
/**
152+
* Validation cases.
153+
*
154+
* @return array
155+
*/
156+
public function validationCases(): array
93157
{
94-
$this->action->getRequest()->expects($this->any())->method('getParam')->willReturn(true);
95-
$this->action->getRequest()->expects($this->any())->method('getFullActionName')
96-
->willReturn('catalog_product_new');
97-
$this->action->execute();
158+
return [
159+
'execute-with-exception' => ['simple\' and true()]|*[self%3a%3ahandle%20or%20self%3a%3alayout',true],
160+
'execute-without-exception' => ['catalog_product_new',false]
161+
];
98162
}
99163
}

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
use Magento\Catalog\Pricing\Render\FinalPriceBox;
1616
use Magento\Framework\App\Cache\StateInterface;
1717
use Magento\Framework\App\Config\ScopeConfigInterface;
18+
use Magento\Framework\App\DeploymentConfig;
1819
use Magento\Framework\App\State;
20+
use Magento\Framework\Config\ConfigOptionsListConstants;
1921
use Magento\Framework\Event\Test\Unit\ManagerStub;
22+
use Magento\Framework\ObjectManagerInterface;
2023
use Magento\Framework\Pricing\Amount\AmountInterface;
2124
use Magento\Framework\Pricing\Price\PriceInterface;
2225
use Magento\Framework\Pricing\PriceInfoInterface;
@@ -96,11 +99,27 @@ class FinalPriceBoxTest extends TestCase
9699
*/
97100
private $minimalPriceCalculator;
98101

102+
/**
103+
* @var DeploymentConfig|MockObject
104+
*/
105+
private $deploymentConfig;
106+
107+
/**
108+
* @var ObjectManagerInterface|MockObject
109+
*/
110+
private $objectManagerMock;
111+
99112
/**
100113
* @inheritDoc
114+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
101115
*/
102116
protected function setUp(): void
103117
{
118+
$this->objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class)
119+
->disableOriginalConstructor()
120+
->onlyMethods(['get'])
121+
->getMockForAbstractClass();
122+
\Magento\Framework\App\ObjectManager::setInstance($this->objectManagerMock);
104123
$this->product = $this->getMockBuilder(Product::class)
105124
->addMethods(['getCanShowPrice'])
106125
->onlyMethods(['getPriceInfo', 'isSalable', 'getId'])
@@ -183,6 +202,11 @@ protected function setUp(): void
183202
->disableOriginalConstructor()
184203
->getMockForAbstractClass();
185204

205+
$this->deploymentConfig = $this->createPartialMock(
206+
DeploymentConfig::class,
207+
['get']
208+
);
209+
186210
$this->minimalPriceCalculator = $this->getMockForAbstractClass(MinimalPriceCalculatorInterface::class);
187211
$this->object = $objectManager->getObject(
188212
FinalPriceBox::class,
@@ -455,6 +479,15 @@ public function testHidePrice(): void
455479
*/
456480
public function testGetCacheKey(): void
457481
{
482+
$this->objectManagerMock->expects($this->any())
483+
->method('get')
484+
->with(DeploymentConfig::class)
485+
->willReturn($this->deploymentConfig);
486+
487+
$this->deploymentConfig->expects($this->any())
488+
->method('get')
489+
->with(ConfigOptionsListConstants::CONFIG_PATH_CRYPT_KEY)
490+
->willReturn('448198e08af35844a42d3c93c1ef4e03');
458491
$result = $this->object->getCacheKey();
459492
$this->assertStringEndsWith('list-category-page', $result);
460493
}

app/code/Magento/Catalog/i18n/en_US.csv

+1
Original file line numberDiff line numberDiff line change
@@ -819,4 +819,5 @@ Details,Details
819819
"Failed to retrieve product links for ""%1""","Failed to retrieve product links for ""%1"""
820820
"The linked product SKU is invalid. Verify the data and try again.","The linked product SKU is invalid. Verify the data and try again."
821821
"The linked products data is invalid. Verify the data and try again.","The linked products data is invalid. Verify the data and try again."
822+
"The url has invalid characters. Please correct and try again.","The url has invalid characters. Please correct and try again."
822823

app/code/Magento/Catalog/view/adminhtml/web/js/category-tree.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55

66
define([
77
'jquery',
8-
'mageUtils',
98
'jquery/ui',
109
'jquery/jstree/jquery.jstree'
11-
], function ($, utils) {
10+
], function ($) {
1211
'use strict';
1312

1413
$.widget('mage.categoryTree', {
@@ -87,7 +86,7 @@ define([
8786
// jscs:disable requireCamelCaseOrUpperCaseIdentifiers
8887
result = {
8988
id: node.id,
90-
text: utils.unescape(node.name) + ' (' + node.product_count + ')',
89+
text: node.name + ' (' + node.product_count + ')',
9190
li_attr: {
9291
class: node.cls + (!!node.disabled ? ' disabled' : '') //eslint-disable-line no-extra-boolean-cast
9392
},

0 commit comments

Comments
 (0)