Skip to content

Commit c35a2f9

Browse files
Merge branch '2.4-develop' into 2.4-develop-prs
2 parents 8f9f4a0 + 25822df commit c35a2f9

File tree

20 files changed

+504
-92
lines changed

20 files changed

+504
-92
lines changed

app/code/Magento/Authorization/Test/Fixture/Role.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99

1010
use Magento\Authorization\Model\Acl\Role\Group;
1111
use Magento\Authorization\Model\ResourceModel\Role as RoleResource;
12+
use Magento\Authorization\Model\RoleFactory;
13+
use Magento\Authorization\Model\RulesFactory;
1214
use Magento\Authorization\Model\UserContextInterface;
1315
use Magento\Framework\DataObject;
14-
use Magento\SharedCatalog\Model\SharedCatalogFactory;
1516
use Magento\TestFramework\Fixture\Data\ProcessorInterface;
1617
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
17-
use Magento\Authorization\Model\RoleFactory;
18-
use Magento\Authorization\Model\RulesFactory;
19-
use Magento\User\Model\UserFactory;
2018

2119
/**
2220
* Creating a new admin role

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,23 @@
105105
<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct1.name$$ +$$$simpleProduct1.price$$.00" stepKey="selectOption0Product0"/>
106106
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct1.name$$ +$$$simpleProduct1.price$$.00" stepKey="checkOption0Product0"/>
107107
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="fillQuantity00"/>
108-
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="checkQuantity00"/>
108+
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="03" stepKey="checkQuantity00"/>
109109

110110
<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct2.name$$ +$$$simpleProduct2.price$$.00" stepKey="selectOption0Product1"/>
111111
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$simpleProduct2.name$$ +$$$simpleProduct2.price$$.00" stepKey="checkOption0Product1"/>
112112
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="fillQuantity01"/>
113-
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="3" stepKey="checkQuantity01"/>
113+
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="03" stepKey="checkQuantity01"/>
114114

115115
<!--"Radio Buttons" type option-->
116116
<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="selectOption1Product0"/>
117117
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="checkOption1Product0"/>
118118
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="fillQuantity10"/>
119-
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="checkQuantity10"/>
119+
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="03" stepKey="checkQuantity10"/>
120120

121121
<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '2')}}" stepKey="selectOption1Product1"/>
122122
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '2')}}" stepKey="checkOption1Product1"/>
123123
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="fillQuantity11"/>
124-
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="3" stepKey="checkQuantity11"/>
124+
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="03" stepKey="checkQuantity11"/>
125125

126126
<!--"Checkbox" type option-->
127127
<!--This option does not support user defined quantities-->

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<!--"Drop-down" type option-->
8181
<selectOption selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$createProduct1.name$$ +$$$createProduct1.price$$.00" stepKey="selectOption0Product0"/>
8282
<seeOptionIsSelected selector="{{StorefrontBundledSection.dropDownOptionOneProducts('Option One')}}" userInput="$$createProduct1.name$$ +$$$createProduct1.price$$.00" stepKey="checkOption0Product0"/>
83+
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-" stepKey="emptyDropdownQuantity"/>
8384
<fillField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-1" stepKey="fillQuantity00"/>
8485
<seeInField selector="{{StorefrontBundledSection.dropDownOptionOneQuantity('Option One')}}" userInput="-1" stepKey="checkQuantity00"/>
8586
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCartDropDown"/>
@@ -88,6 +89,7 @@
8889
<!--"Radio Buttons" type option-->
8990
<checkOption selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="selectOption1Product0"/>
9091
<seeCheckboxIsChecked selector="{{StorefrontBundledSection.radioButtonOptionTwoProducts('Option Two', '1')}}" stepKey="checkOption1Product0"/>
92+
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-" stepKey="emptyRadioQuantity"/>
9193
<fillField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-1" stepKey="fillQuantity10"/>
9294
<seeInField selector="{{StorefrontBundledSection.radioButtonOptionTwoQuantity('Option Two')}}" userInput="-1" stepKey="checkQuantity10"/>
9395
<click selector="{{StorefrontBundledSection.addToCartConfigured}}" stepKey="clickAddToCartRadioButton"/>

app/code/Magento/Bundle/ViewModel/ValidateQuantity.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
use Magento\Framework\Serialize\Serializer\Json;
1111
use Magento\Framework\View\Element\Block\ArgumentInterface;
12-
use Magento\Catalog\Block\Product\View as ProductView;
1312

1413
/**
1514
* ViewModel for Bundle Option Block
@@ -21,27 +20,24 @@ class ValidateQuantity implements ArgumentInterface
2120
*/
2221
private $serializer;
2322

24-
/**
25-
* @var ProductView
26-
*/
27-
private $productView;
28-
2923
/**
3024
* @param Json $serializer
31-
* @param ProductView $productView
3225
*/
3326
public function __construct(
34-
Json $serializer,
35-
ProductView $productView
27+
Json $serializer
3628
) {
3729
$this->serializer = $serializer;
38-
$this->productView = $productView;
3930
}
4031

32+
/**
33+
* Returns quantity validator.
34+
*
35+
* @return string
36+
*/
4137
public function getQuantityValidators(): string
4238
{
43-
return $this->serializer->serialize(
44-
$this->productView->getQuantityValidators()
45-
);
39+
$validators['validate-item-quantity'] = [];
40+
41+
return $this->serializer->serialize($validators);
4642
}
4743
}

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -387,15 +387,9 @@ define([
387387
function isValidQty(bundleOption) {
388388
var isValid = true,
389389
qtyElem = bundleOption.data('qtyField'),
390-
bundleOptionType = bundleOption.prop('type'),
391-
qtyValidator = qtyElem.data('validate') &&
392-
typeof qtyElem.data('validate')['validate-item-quantity'] === 'object' ?
393-
qtyElem.data('validate')['validate-item-quantity'] : null;
394-
395-
if (['radio', 'select-one'].includes(bundleOptionType) &&
396-
qtyValidator &&
397-
(qtyElem.val() < qtyValidator.minAllowed || qtyElem.val() > qtyValidator.maxAllowed)
398-
) {
390+
bundleOptionType = bundleOption.prop('type');
391+
392+
if (['radio', 'select-one'].includes(bundleOptionType) && qtyElem.val() < 0) {
399393
isValid = false;
400394
}
401395

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</actionGroup>
5252
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckMiniQtyCheckBox"/>
5353
<actionGroup ref="AdminSetMinAllowedQtyForProductActionGroup" stepKey="fillMiniAllowedQty">
54-
<argument name="qty" value="1"/>
54+
<argument name="qty" value="4"/>
5555
</actionGroup>
5656
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="uncheckMaxQtyCheckBox"/>
5757
<actionGroup ref="AdminSetMaxAllowedQtyForProductActionGroup" stepKey="fillMaxAllowedQty">
@@ -107,16 +107,20 @@
107107
<!--Add Product to the cart-->
108108
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="fillProductQuantity"/>
109109
<actionGroup ref="StorefrontAddProductToCartWithQtyActionGroup" stepKey="addToCartFromStorefrontProductPage">
110+
<argument name="productQty" value="4"/>
111+
</actionGroup>
112+
<actionGroup ref="StorefrontAddProductToCartWithQtyActionGroup" stepKey="addAdditionalProductToCart">
110113
<argument name="productQty" value="1"/>
111114
</actionGroup>
112115
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeSuccessSaveMessage"/>
113-
<seeElement selector="{{StorefrontMinicartSection.quantity(1)}}" stepKey="seeAddedProductQuantityInCart"/>
116+
<seeElement selector="{{StorefrontMinicartSection.quantity(6)}}" stepKey="seeAddedProductQuantityInCart"/>
114117
<actionGroup ref="StorefrontClickOnMiniCartActionGroup" stepKey="clickOnMiniCart"/>
118+
<executeJS function="return {{SimpleProduct.price}} * 5" stepKey="expectedCartSubtotal"/>
115119
<actionGroup ref="AssertStorefrontMiniCartItemsActionGroup" stepKey="seeProductNameInMiniCart">
116120
<argument name="productName" value="{{SimpleProduct.name}}"/>
117121
<argument name="productPrice" value="{{SimpleProduct.price}}"/>
118-
<argument name="cartSubtotal" value="{{SimpleProduct.price}}" />
119-
<argument name="qty" value="1"/>
122+
<argument name="cartSubtotal" value="{$expectedCartSubtotal}" />
123+
<argument name="qty" value="5"/>
120124
</actionGroup>
121125
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeProductPriceInMiniCart"/>
122126
<comment userInput="Comment is added to preserve the step key for backward compatibility" stepKey="seeCheckOutButtonInMiniCart"/>

app/code/Magento/CatalogInventory/Block/Plugin/ProductView.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public function __construct(
2424
}
2525

2626
/**
27+
* Adds quantities validator.
28+
*
2729
* @param \Magento\Catalog\Block\Product\View $block
2830
* @param array $validators
2931
* @return array
@@ -38,7 +40,6 @@ public function afterGetQuantityValidators(
3840
);
3941

4042
$params = [];
41-
$params['minAllowed'] = (float)$stockItem->getMinSaleQty();
4243
if ($stockItem->getMaxSaleQty()) {
4344
$params['maxAllowed'] = (float)$stockItem->getMaxSaleQty();
4445
}

app/code/Magento/CatalogInventory/Test/Unit/Block/Plugin/ProductViewTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function testAfterGetQuantityValidators()
5959
{
6060
$result = [
6161
'validate-item-quantity' => [
62-
'minAllowed' => 0.5,
6362
'maxAllowed' => 5.0,
6463
'qtyIncrements' => 3.0
6564
]
@@ -85,7 +84,6 @@ public function testAfterGetQuantityValidators()
8584
->method('getStockItem')
8685
->with('productId', 'websiteId')
8786
->willReturn($this->stockItem);
88-
$this->stockItem->expects($this->once())->method('getMinSaleQty')->willReturn(0.5);
8987
$this->stockItem->expects($this->any())->method('getMaxSaleQty')->willReturn(5);
9088
$this->stockItem->expects($this->any())->method('getQtyIncrements')->willReturn(3);
9189

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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\CatalogRule\Test\Fixture\Data;
9+
10+
use Magento\CatalogRule\Model\Rule\Action\Collection;
11+
use Magento\Framework\Serialize\Serializer\Json;
12+
13+
class ActionsSerializer
14+
{
15+
/**
16+
* @var Json
17+
*/
18+
private Json $json;
19+
20+
/**
21+
* @param Json $json
22+
*/
23+
public function __construct(
24+
Json $json
25+
) {
26+
$this->json = $json;
27+
}
28+
29+
/**
30+
* Normalizes and serializes actions data
31+
*
32+
* @param array $data
33+
* @return string
34+
*/
35+
public function serialize(array $data): string
36+
{
37+
return $this->json->serialize($this->normalize($data));
38+
}
39+
40+
/**
41+
* Normalizes actions data
42+
*
43+
* @param array $data
44+
* @return array
45+
*/
46+
private function normalize(array $data) : array
47+
{
48+
$actions = $data;
49+
$actions += [
50+
'type' => Collection::class,
51+
'attribute' => null,
52+
'value' => null,
53+
'operator' => '=',
54+
];
55+
return $actions;
56+
}
57+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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\CatalogRule\Test\Fixture\Data;
9+
10+
use Magento\CatalogRule\Model\Rule\Condition\Combine;
11+
use Magento\CatalogRule\Model\Rule\Condition\Product;
12+
use Magento\Framework\Serialize\Serializer\Json;
13+
14+
class ConditionsSerializer
15+
{
16+
/**
17+
* @var Json
18+
*/
19+
private Json $json;
20+
21+
/**
22+
* @param Json $json
23+
*/
24+
public function __construct(
25+
Json $json
26+
) {
27+
$this->json = $json;
28+
}
29+
30+
/**
31+
* Normalizes and serializes conditions data
32+
*
33+
* @param array $data
34+
* @return string
35+
*/
36+
public function serialize(array $data): string
37+
{
38+
return $this->json->serialize($this->normalize($data));
39+
}
40+
41+
/**
42+
* Normalizes conditions data
43+
*
44+
* @param array $data
45+
* @return array
46+
*/
47+
private function normalize(array $data) : array
48+
{
49+
$conditions = $data;
50+
if (array_is_list($conditions)) {
51+
$conditions = [
52+
'conditions' => $conditions,
53+
];
54+
}
55+
$conditions += [
56+
'type' => Combine::class,
57+
'attribute' => null,
58+
'value' => true,
59+
'operator' => null,
60+
'aggregator' => 'all',
61+
'is_value_processed' => null,
62+
'conditions' => [
63+
64+
],
65+
];
66+
$subConditions = $conditions['conditions'];
67+
$conditions['conditions'] = [];
68+
69+
foreach ($subConditions as $condition) {
70+
if (isset($condition['conditions']) && array_is_list($condition)) {
71+
$condition = $this->normalize($condition);
72+
} else {
73+
$condition += [
74+
'type' => Product::class,
75+
'attribute' => null,
76+
'value' => null,
77+
'operator' => '==',
78+
'is_value_processed' => false,
79+
];
80+
}
81+
82+
$conditions['conditions'][] = $condition;
83+
}
84+
return $conditions;
85+
}
86+
}

0 commit comments

Comments
 (0)