Skip to content

Commit 79215d3

Browse files
merge magento/2.4-develop into magento-tsg/2.4-develop-pr6
2 parents 8bfeb2b + 1027e02 commit 79215d3

File tree

49 files changed

+607
-106
lines changed

Some content is hidden

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

49 files changed

+607
-106
lines changed

app/code/Magento/Catalog/Model/Product/Attribute/Backend/TierPrice/UpdateHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function updateValues(array $valuesToUpdate, array $oldValues): bool
129129
{
130130
$isChanged = false;
131131
foreach ($valuesToUpdate as $key => $value) {
132-
if ((!empty($value['value'])
132+
if ((($value['value'])!== null
133133
&& (float)$oldValues[$key]['price'] !== $this->localeFormat->getNumber($value['value'])
134134
) || $this->getPercentage($oldValues[$key]) !== $this->getPercentage($value)
135135
) {

app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/TierPrice/UpdateHandlerTest.php

Lines changed: 116 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
namespace Magento\Catalog\Test\Unit\Model\Attribute\Backend\TierPrice;
99

10-
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
11-
use Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\UpdateHandler;
12-
use Magento\Store\Model\StoreManagerInterface;
1310
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
11+
use Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\UpdateHandler;
12+
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice;
1413
use Magento\Customer\Api\GroupManagementInterface;
1514
use Magento\Framework\EntityManager\MetadataPool;
16-
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
16+
use Magento\Store\Model\StoreManagerInterface;
1717

1818
/**
1919
* Unit tests for \Magento\Catalog\Model\Product\Attribute\Backend\TierPrice\UpdateHandler
@@ -95,20 +95,27 @@ protected function setUp()
9595
);
9696
}
9797

98-
public function testExecute(): void
99-
{
100-
$newTierPrices = [
101-
['website_id' => 0, 'price_qty' => 2, 'cust_group' => 0, 'price' => 15],
102-
['website_id' => 0, 'price_qty' => 3, 'cust_group' => 3200, 'price' => null, 'percentage_value' => 20]
103-
];
104-
$priceIdToDelete = 2;
105-
$originalTierPrices = [
106-
['price_id' => 1, 'website_id' => 0, 'price_qty' => 2, 'cust_group' => 0, 'price' => 10],
107-
['price_id' => $priceIdToDelete, 'website_id' => 0, 'price_qty' => 4, 'cust_group' => 0, 'price' => 20],
108-
];
109-
$linkField = 'entity_id';
110-
$productId = 10;
111-
$originalProductId = 11;
98+
/**
99+
* Verify update handle.
100+
*
101+
* @param array $newTierPrices
102+
* @param array $originalTierPrices
103+
* @param int $priceIdToDelete
104+
* @param string $linkField
105+
* @param int $productId
106+
* @param int $originalProductId
107+
* @throws \Magento\Framework\Exception\InputException
108+
*
109+
* @dataProvider configDataProvider
110+
*/
111+
public function testExecute(
112+
$newTierPrices,
113+
$originalTierPrices,
114+
$priceIdToDelete,
115+
$linkField,
116+
$productId,
117+
$originalProductId
118+
): void {
112119

113120
/** @var \PHPUnit_Framework_MockObject_MockObject $product */
114121
$product = $this->getMockBuilder(\Magento\Catalog\Api\Data\ProductInterface::class)
@@ -128,8 +135,12 @@ public function testExecute(): void
128135
['entity_id', $originalProductId]
129136
]
130137
);
138+
131139
$product->expects($this->atLeastOnce())->method('getStoreId')->willReturn(0);
132-
$product->expects($this->atLeastOnce())->method('setData')->with('tier_price_changed', 1);
140+
141+
$product->expects($this->atLeastOnce())
142+
->method('setData')
143+
->with('tier_price_changed', 1);
133144
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
134145
->disableOriginalConstructor()
135146
->setMethods(['getWebsiteId'])
@@ -163,11 +174,12 @@ public function testExecute(): void
163174
$this->tierPriceResource->expects($this->exactly(2))->method('savePriceData')->willReturnSelf();
164175
$this->tierPriceResource->expects($this->once())->method('deletePriceData')
165176
->with($productId, null, $priceIdToDelete);
166-
167177
$this->assertEquals($product, $this->updateHandler->execute($product));
168178
}
169179

170180
/**
181+
* Verify update handle with exception.
182+
*
171183
* @expectedException \Magento\Framework\Exception\InputException
172184
* @expectedExceptionMessage Tier prices data should be array, but actually other type is received
173185
*/
@@ -190,4 +202,88 @@ public function testExecuteWithException(): void
190202

191203
$this->updateHandler->execute($product);
192204
}
205+
206+
/**
207+
* Returns test parameters.
208+
*
209+
* @return array
210+
*/
211+
public function configDataProvider()
212+
{
213+
return [
214+
[
215+
[
216+
[
217+
'website_id' => 0,
218+
'price_qty' => 2,
219+
'cust_group' => 0,
220+
'price' => 15
221+
],
222+
[
223+
'website_id' => 0,
224+
'price_qty' => 3,
225+
'cust_group' => 3200,
226+
'price' => null,
227+
'percentage_value' => 20
228+
]
229+
],
230+
[
231+
[
232+
'price_id' => 1,
233+
'website_id' => 0,
234+
'price_qty' => 2,
235+
'cust_group' => 0,
236+
'price' => 10],
237+
[
238+
'price_id' => 2,
239+
'website_id' => 0,
240+
'price_qty' => 4,
241+
'cust_group' => 0,
242+
'price' => 20
243+
],
244+
],
245+
2,
246+
'entity_id',
247+
10,
248+
11
249+
],
250+
[
251+
[
252+
[
253+
'website_id' => 0,
254+
'price_qty' => 2,
255+
'cust_group' => 0,
256+
'price' => 0
257+
],
258+
[
259+
'website_id' => 0,
260+
'price_qty' => 3,
261+
'cust_group' => 3200,
262+
'price' => null,
263+
'percentage_value' => 20
264+
]
265+
],
266+
[
267+
[
268+
'price_id' => 1,
269+
'website_id' => 0,
270+
'price_qty' => 2,
271+
'cust_group' => 0,
272+
'price' => 10
273+
],
274+
[
275+
'price_id' => 2,
276+
'website_id' => 0,
277+
'price_qty' => 4,
278+
'cust_group' => 0,
279+
'price' => 20
280+
],
281+
],
282+
2,
283+
'entity_id',
284+
10,
285+
11
286+
]
287+
];
288+
}
193289
}

app/code/Magento/CatalogWidget/Block/Product/ProductsList.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use Magento\Catalog\Api\CategoryRepositoryInterface;
1010
use Magento\Catalog\Block\Product\AbstractProduct;
11+
use Magento\Catalog\Block\Product\Context;
1112
use Magento\Catalog\Block\Product\Widget\Html\Pager;
1213
use Magento\Catalog\Model\Product;
1314
use Magento\Catalog\Model\Product\Visibility;
@@ -16,7 +17,7 @@
1617
use Magento\Catalog\Pricing\Price\FinalPrice;
1718
use Magento\CatalogWidget\Model\Rule;
1819
use Magento\Framework\App\ActionInterface;
19-
use Magento\Framework\App\Http\Context;
20+
use Magento\Framework\App\Http\Context as HttpContext;
2021
use Magento\Framework\App\ObjectManager;
2122
use Magento\Framework\DataObject\IdentityInterface;
2223
use Magento\Framework\Exception\LocalizedException;
@@ -27,7 +28,7 @@
2728
use Magento\Framework\View\LayoutFactory;
2829
use Magento\Framework\View\LayoutInterface;
2930
use Magento\Rule\Model\Condition\Combine;
30-
use Magento\Rule\Model\Condition\Sql\Builder;
31+
use Magento\Rule\Model\Condition\Sql\Builder as SqlBuilder;
3132
use Magento\Widget\Block\BlockInterface;
3233
use Magento\Widget\Helper\Conditions;
3334

@@ -69,7 +70,7 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
6970
protected $pager;
7071

7172
/**
72-
* @var Context
73+
* @var HttpContext
7374
*/
7475
protected $httpContext;
7576

@@ -88,7 +89,7 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
8889
protected $productCollectionFactory;
8990

9091
/**
91-
* @var Builder
92+
* @var SqlBuilder
9293
*/
9394
protected $sqlBuilder;
9495

@@ -135,34 +136,34 @@ class ProductsList extends AbstractProduct implements BlockInterface, IdentityIn
135136
private $categoryRepository;
136137

137138
/**
138-
* @param \Magento\Catalog\Block\Product\Context $context
139+
* @param Context $context
139140
* @param CollectionFactory $productCollectionFactory
140141
* @param Visibility $catalogProductVisibility
141-
* @param Context $httpContext
142-
* @param Builder $sqlBuilder
142+
* @param HttpContext $httpContext
143+
* @param SqlBuilder $sqlBuilder
143144
* @param Rule $rule
144145
* @param Conditions $conditionsHelper
145-
* @param CategoryRepositoryInterface $categoryRepository
146146
* @param array $data
147147
* @param Json|null $json
148148
* @param LayoutFactory|null $layoutFactory
149149
* @param EncoderInterface|null $urlEncoder
150+
* @param CategoryRepositoryInterface|null $categoryRepository
150151
*
151152
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
152153
*/
153154
public function __construct(
154-
\Magento\Catalog\Block\Product\Context $context,
155+
Context $context,
155156
CollectionFactory $productCollectionFactory,
156157
Visibility $catalogProductVisibility,
157-
Context $httpContext,
158-
Builder $sqlBuilder,
158+
HttpContext $httpContext,
159+
SqlBuilder $sqlBuilder,
159160
Rule $rule,
160161
Conditions $conditionsHelper,
161-
CategoryRepositoryInterface $categoryRepository,
162162
array $data = [],
163163
Json $json = null,
164164
LayoutFactory $layoutFactory = null,
165-
EncoderInterface $urlEncoder = null
165+
EncoderInterface $urlEncoder = null,
166+
CategoryRepositoryInterface $categoryRepository = null
166167
) {
167168
$this->productCollectionFactory = $productCollectionFactory;
168169
$this->catalogProductVisibility = $catalogProductVisibility;
@@ -173,7 +174,8 @@ public function __construct(
173174
$this->json = $json ?: ObjectManager::getInstance()->get(Json::class);
174175
$this->layoutFactory = $layoutFactory ?: ObjectManager::getInstance()->get(LayoutFactory::class);
175176
$this->urlEncoder = $urlEncoder ?: ObjectManager::getInstance()->get(EncoderInterface::class);
176-
$this->categoryRepository = $categoryRepository;
177+
$this->categoryRepository = $categoryRepository ?? ObjectManager::getInstance()
178+
->get(CategoryRepositoryInterface::class);
177179
parent::__construct(
178180
$context,
179181
$data

app/code/Magento/Dhl/etc/module.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Dhl" >
10-
</module>
9+
<module name="Magento_Dhl"/>
1110
</config>

app/code/Magento/Payment/Model/MethodList.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,29 @@ class MethodList
3939
*/
4040
private $paymentMethodInstanceFactory;
4141

42+
/**
43+
* @var array
44+
*/
45+
private $additionalChecks;
46+
4247
/**
4348
* @param \Magento\Payment\Helper\Data $paymentHelper
44-
* @param Checks\SpecificationFactory $specificationFactory
49+
* @param Checks\SpecificationFactory $specificationFactory
50+
* @param array $additionalChecks
4551
*/
4652
public function __construct(
4753
\Magento\Payment\Helper\Data $paymentHelper,
48-
\Magento\Payment\Model\Checks\SpecificationFactory $specificationFactory
54+
\Magento\Payment\Model\Checks\SpecificationFactory $specificationFactory,
55+
array $additionalChecks = []
4956
) {
5057
$this->paymentHelper = $paymentHelper;
5158
$this->methodSpecificationFactory = $specificationFactory;
59+
$this->additionalChecks = $additionalChecks;
5260
}
5361

5462
/**
63+
* Returns all available payment methods for the given quote.
64+
*
5565
* @param \Magento\Quote\Api\Data\CartInterface $quote
5666
* @return \Magento\Payment\Model\MethodInterface[]
5767
*/
@@ -80,12 +90,15 @@ public function getAvailableMethods(\Magento\Quote\Api\Data\CartInterface $quote
8090
protected function _canUseMethod($method, \Magento\Quote\Api\Data\CartInterface $quote)
8191
{
8292
return $this->methodSpecificationFactory->create(
83-
[
84-
AbstractMethod::CHECK_USE_CHECKOUT,
85-
AbstractMethod::CHECK_USE_FOR_COUNTRY,
86-
AbstractMethod::CHECK_USE_FOR_CURRENCY,
87-
AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX,
88-
]
93+
array_merge(
94+
[
95+
AbstractMethod::CHECK_USE_CHECKOUT,
96+
AbstractMethod::CHECK_USE_FOR_COUNTRY,
97+
AbstractMethod::CHECK_USE_FOR_CURRENCY,
98+
AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX,
99+
],
100+
$this->additionalChecks
101+
)
89102
)->isApplicable(
90103
$method,
91104
$quote

0 commit comments

Comments
 (0)