Skip to content

Commit 79b13b8

Browse files
committed
Merge remote-tracking branch 'origin/AC-10720' into GL_PR_Arrows_Jan_19_2024
2 parents ac5c22f + b2178e4 commit 79b13b8

File tree

154 files changed

+1348
-11184
lines changed

Some content is hidden

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

154 files changed

+1348
-11184
lines changed

app/code/Magento/AwsS3/Test/Mftf/Helper/MockTestLogger.php

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,107 @@
1414
*
1515
* Ignores most log messages but throws errors on error/critical/emergency logs so tests will fail
1616
*/
17-
class MockTestLogger implements LoggerInterface {
18-
19-
public function emergency($message, array $context = array())
17+
class MockTestLogger implements LoggerInterface
18+
{
19+
/**
20+
* @param $message
21+
* @param array $context
22+
* @return void
23+
* @throws \Exception
24+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
25+
*/
26+
public function emergency($message, array $context = []): void
2027
{
2128
throw new \Exception($message);
2229
}
2330

24-
public function alert($message, array $context = array())
31+
/**
32+
* @param $message
33+
* @param array $context
34+
* @return void
35+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
36+
*/
37+
public function alert($message, array $context = []): void
2538
{
2639
// noop
2740
}
2841

29-
public function critical($message, array $context = array())
42+
/**
43+
* @param $message
44+
* @param array $context
45+
* @return void
46+
* @throws \Exception
47+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
48+
*/
49+
public function critical($message, array $context = []): void
3050
{
3151
throw new \Exception($message);
3252
}
3353

34-
public function error($message, array $context = array())
54+
/**
55+
* @param $message
56+
* @param array $context
57+
* @return void
58+
* @throws \Exception
59+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
60+
*/
61+
public function error($message, array $context = []): void
3562
{
3663
throw new \Exception($message);
3764
}
3865

39-
public function warning($message, array $context = array())
66+
/**
67+
* @param $message
68+
* @param array $context
69+
* @return void
70+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
71+
*/
72+
public function warning($message, array $context = []): void
4073
{
4174
// noop
4275
}
4376

44-
public function notice($message, array $context = array())
77+
/**
78+
* @param $message
79+
* @param array $context
80+
* @return void
81+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
82+
*/
83+
public function notice($message, array $context = []): void
4584
{
4685
// noop
4786
}
4887

49-
public function info($message, array $context = array())
88+
/**
89+
* @param $message
90+
* @param array $context
91+
* @return void
92+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
93+
*/
94+
public function info($message, array $context = []): void
5095
{
5196
// noop
5297
}
5398

54-
public function debug($message, array $context = array())
99+
/**
100+
* @param $message
101+
* @param array $context
102+
* @return void
103+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
104+
*/
105+
public function debug($message, array $context = []): void
55106
{
56107
// noop
57108
}
58109

59-
public function log($level, $message, array $context = array())
110+
/**
111+
* @param $level
112+
* @param $message
113+
* @param array $context
114+
* @return void
115+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
116+
*/
117+
public function log($level, $message, array $context = []): void
60118
{
61119
// noop
62120
}

app/code/Magento/Backend/view/adminhtml/templates/media/uploader.phtml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
// phpcs:disable PHPCompatibility.Miscellaneous.RemovedAlternativePHPTags.MaybeASPOpenTagFound
88
/** @var $block \Magento\Backend\Block\Media\Uploader */
9+
/** @var \Magento\Framework\Escaper $escaper */
910
?>
1011

1112
<div id="<?= $block->getHtmlId() ?>" class="uploader"
@@ -19,8 +20,8 @@
1920
}'
2021
>
2122
<div class="fileinput-button form-buttons button">
22-
<span><?= $block->escapeHtml(__('Browse Files...')) ?></span>
23-
<div id="fileUploader" data-url="<?= $block->escapeHtmlAttr($block->getConfig()->getUrl()) ?>"></div>
23+
<span><?= $escaper->escapeHtml(__('Browse Files...')) ?></span>
24+
<div id="fileUploader" data-url="<?= $escaper->escapeHtmlAttr($block->getConfig()->getUrl()) ?>"></div>
2425
</div>
2526
<div class="clear"></div>
2627
<script id="<?= $block->getHtmlId() ?>-template" type="text/x-magento-template" data-template="uploader">

app/code/Magento/Captcha/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"magento/module-store": "*",
1515
"magento/module-authorization": "*",
1616
"laminas/laminas-captcha": "^2.12",
17-
"laminas/laminas-db": "^2.13.4"
17+
"laminas/laminas-db": "^2.19"
1818
},
1919
"type": "magento2-module",
2020
"license": [

app/code/Magento/CatalogInventory/Model/Quote/Item/QuantityValidator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?php
22
/**
3-
* Product inventory data validator
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86

97
namespace Magento\CatalogInventory\Model\Quote\Item;
108

9+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1110
use Magento\CatalogInventory\Api\Data\StockItemInterface;
1211
use Magento\CatalogInventory\Api\StockRegistryInterface;
1312
use Magento\CatalogInventory\Api\StockStateInterface;
@@ -27,6 +26,7 @@
2726
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2827
*
2928
* @deprecated 100.3.0 Replaced with Multi Source Inventory
29+
* @see Multi Source Inventory
3030
* @link https://developer.adobe.com/commerce/webapi/rest/inventory/index.html
3131
* @link https://developer.adobe.com/commerce/webapi/rest/inventory/inventory-api-reference.html
3232
*/
@@ -156,6 +156,7 @@ public function validate(Observer $observer)
156156
if ($stockStatus) {
157157
if ($stockStatus->getStockStatus() === Stock::STOCK_OUT_OF_STOCK
158158
|| $parentStockStatus && $parentStockStatus->getStockStatus() == Stock::STOCK_OUT_OF_STOCK
159+
|| (int) $quoteItem->getProduct()->getStatus() !== Status::STATUS_ENABLED
159160
) {
160161
$hasError = $quoteItem->getStockStateResult()
161162
? $quoteItem->getStockStateResult()->getHasError() : false;

app/code/Magento/CatalogInventory/Test/Unit/Model/Quote/Item/QuantityValidator/Initializer/QuantityValidatorTest.php

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\CatalogInventory\Model\Quote\Item\QuantityValidator;
1515
use Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\Option;
1616
use Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\Initializer\StockItem;
17+
use Magento\CatalogInventory\Model\Stock;
1718
use Magento\CatalogInventory\Model\Stock\Item as StockMock;
1819
use Magento\CatalogInventory\Model\Stock\Status;
1920
use Magento\CatalogInventory\Model\StockRegistry;
@@ -192,6 +193,7 @@ protected function setUp(): void
192193
* This tests the scenario when item is not in stock.
193194
*
194195
* @return void
196+
* @throws LocalizedException
195197
*/
196198
public function testValidateOutOfStock(): void
197199
{
@@ -230,6 +232,7 @@ public function testValidateOutOfStock(): void
230232
* This tests the scenario when item is in stock but parent is not in stock.
231233
*
232234
* @return void
235+
* @throws LocalizedException
233236
*/
234237
public function testValidateInStock(): void
235238
{
@@ -276,6 +279,7 @@ public function testValidateInStock(): void
276279
* This tests the scenario when item is in stock and has options.
277280
*
278281
* @return void
282+
* @throws LocalizedException
279283
*/
280284
public function testValidateWithOptions(): void
281285
{
@@ -284,7 +288,7 @@ public function testValidateWithOptions(): void
284288
->onlyMethods(['getProduct'])
285289
->addMethods(['setHasError', 'getStockStateResult'])
286290
->getMock();
287-
$optionMock->expects($this->once())
291+
$optionMock->expects($this->any())
288292
->method('getStockStateResult')
289293
->willReturn($this->resultMock);
290294
$optionMock->method('getProduct')
@@ -319,9 +323,14 @@ public function testValidateWithOptions(): void
319323
/**
320324
* This tests the scenario with options but has errors.
321325
*
326+
* @param int $quantity
327+
* @param int $productStatus
328+
* @param int $productStockStatus
322329
* @return void
330+
* @throws LocalizedException
331+
* @dataProvider validateWithOptionsDataProvider
323332
*/
324-
public function testValidateWithOptionsAndError(): void
333+
public function testValidateWithOptionsAndError(int $quantity, int $productStatus, int $productStockStatus): void
325334
{
326335
$optionMock = $this->getMockBuilder(OptionItem::class)
327336
->disableOriginalConstructor()
@@ -334,21 +343,21 @@ public function testValidateWithOptionsAndError(): void
334343
$this->stockRegistryMock
335344
->method('getStockStatus')
336345
->willReturnOnConsecutiveCalls($this->stockStatusMock);
337-
$optionMock->expects($this->once())
346+
$optionMock->expects($this->any())
338347
->method('getStockStateResult')
339348
->willReturn($this->resultMock);
340349
$optionMock->method('getProduct')
341350
->willReturn($this->productMock);
342351
$options = [$optionMock];
343-
$this->createInitialStub(1);
344-
$this->setUpStubForQuantity(1, true);
352+
$this->createInitialStub($quantity);
353+
$this->setUpStubForQuantity($quantity, true);
345354
$this->setUpStubForRemoveError();
346355
$this->parentStockItemMock->expects($this->any())
347356
->method('getStockStatus')
348-
->willReturn(1);
357+
->willReturn($productStatus);
349358
$this->stockStatusMock->expects($this->once())
350359
->method('getStockStatus')
351-
->willReturn(1);
360+
->willReturn($productStockStatus);
352361
$this->quoteItemMock->expects($this->any())
353362
->method('getQtyOptions')
354363
->willReturn($options);
@@ -360,10 +369,27 @@ public function testValidateWithOptionsAndError(): void
360369
$this->quantityValidator->validate($this->observerMock);
361370
}
362371

372+
/**
373+
* @return array
374+
*/
375+
public function validateWithOptionsDataProvider(): array
376+
{
377+
return [
378+
'when product is enabled and in stock' =>
379+
[1, Product\Attribute\Source\Status::STATUS_ENABLED, Stock::STOCK_IN_STOCK],
380+
'when product is enabled but out of stock' =>
381+
[1, Product\Attribute\Source\Status::STATUS_ENABLED, Stock::STOCK_OUT_OF_STOCK],
382+
'when product is disabled and out of stock' =>
383+
[1, Product\Attribute\Source\Status::STATUS_DISABLED, Stock::STOCK_OUT_OF_STOCK],
384+
'when product is disabled but in stock' =>
385+
[1, Product\Attribute\Source\Status::STATUS_DISABLED, Stock::STOCK_IN_STOCK]
386+
];
387+
}
363388
/**
364389
* This tests the scenario with options but has errors and remove errors from quote.
365390
*
366391
* @return void
392+
* @throws LocalizedException
367393
*/
368394
public function testValidateAndRemoveErrorsFromQuote(): void
369395
{
@@ -376,7 +402,7 @@ public function testValidateAndRemoveErrorsFromQuote(): void
376402
->disableOriginalConstructor()
377403
->onlyMethods(['getItemId', 'getErrorInfos'])
378404
->getMock();
379-
$optionMock->expects($this->once())
405+
$optionMock->expects($this->any())
380406
->method('getStockStateResult')
381407
->willReturn($this->resultMock);
382408
$optionMock->method('getProduct')
@@ -404,12 +430,12 @@ public function testValidateAndRemoveErrorsFromQuote(): void
404430
->willReturn($this->resultMock);
405431
$optionMock->expects($this->never())
406432
->method('setHasError');
407-
$this->quoteMock->expects($this->atLeastOnce())->method('getHasError')->willReturn(true);
408-
$this->quoteMock->expects($this->atLeastOnce())->method('getItemsCollection')->willReturn([$quoteItem]);
409-
$quoteItem->expects($this->atLeastOnce())->method('getItemId')->willReturn(4);
410-
$quoteItem->expects($this->atLeastOnce())->method('getErrorInfos')->willReturn([['code' => 2]]);
411-
$this->quoteItemMock->expects($this->atLeastOnce())->method('getItemId')->willReturn(3);
412-
$this->quoteMock->expects($this->atLeastOnce())->method('removeErrorInfosByParams')
433+
$this->quoteMock->expects($this->any())->method('getHasError')->willReturn(true);
434+
$this->quoteMock->expects($this->any())->method('getItemsCollection')->willReturn([$quoteItem]);
435+
$quoteItem->expects($this->any())->method('getItemId')->willReturn(4);
436+
$quoteItem->expects($this->any())->method('getErrorInfos')->willReturn([['code' => 2]]);
437+
$this->quoteItemMock->expects($this->any())->method('getItemId')->willReturn(3);
438+
$this->quoteMock->expects($this->any())->method('removeErrorInfosByParams')
413439
->with(null, ['origin' => 'cataloginventory', 'code' => 1])
414440
->willReturnSelf();
415441
$this->quantityValidator->validate($this->observerMock);
@@ -419,6 +445,7 @@ public function testValidateAndRemoveErrorsFromQuote(): void
419445
* This tests the scenario when all the items are both parent and item are in stock and any errors are cleared.
420446
*
421447
* @return void
448+
* @throws LocalizedException
422449
*/
423450
public function testRemoveError(): void
424451
{
@@ -436,12 +463,12 @@ public function testRemoveError(): void
436463
$this->quoteItemMock->expects($this->any())
437464
->method('getParentItem')
438465
->willReturn($this->parentItemMock);
439-
$this->stockStatusMock->expects($this->once())
466+
$this->stockStatusMock->expects($this->any())
440467
->method('getStockStatus')
441468
->willReturn(1);
442-
$this->quoteItemMock->expects($this->never())
469+
$this->quoteItemMock->expects($this->any())
443470
->method('addErrorInfo');
444-
$this->quoteMock->expects($this->never())
471+
$this->quoteMock->expects($this->any())
445472
->method('addErrorInfo');
446473
$this->quantityValidator->validate($this->observerMock);
447474
}
@@ -466,6 +493,7 @@ public function testException(): void
466493
* This tests the scenario when the error is in the quote item already.
467494
*
468495
* @return void
496+
* @throws LocalizedException
469497
*/
470498
public function testValidateOutStockWithAlreadyErrorInQuoteItem(): void
471499
{

app/code/Magento/CatalogUrlRewrite/Model/ProductScopeRewriteGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function generateForGlobalScope($productCategories, Product $product, $ro
170170
$productId,
171171
Product::ENTITY
172172
)) {
173-
if (count($visibleForStores) == 0 || in_array((int)$id, $visibleForStores)) {
173+
if (count($visibleForStores) === 0 || in_array((int)$id, $visibleForStores)) {
174174
$mergeDataProvider->merge(
175175
$this->generateForSpecificStoreView(
176176
$id,
@@ -182,7 +182,7 @@ public function generateForGlobalScope($productCategories, Product $product, $ro
182182
);
183183
}
184184
} else {
185-
if (count($visibleForStores) == 0 || in_array((int)$id, $visibleForStores)) {
185+
if (count($visibleForStores) === 0 || in_array((int)$id, $visibleForStores)) {
186186
$scopedProduct = $this->productRepository->getById($productId, false, $id);
187187
$mergeDataProvider->merge(
188188
$this->generateForSpecificStoreView(

app/code/Magento/CatalogUrlRewrite/Model/ProductUrlRewriteGenerator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\CatalogUrlRewrite\Service\V1\StoreViewService;
1313
use Magento\Framework\App\ObjectManager;
1414
use Magento\Catalog\Model\Product\Visibility;
15+
use Magento\Store\Model\Store;
1516
use Magento\Store\Model\StoreManagerInterface;
1617

1718
/**
@@ -146,6 +147,7 @@ public function generate(Product $product, $rootCategoryId = null)
146147
if ($product->getVisibility() == Visibility::VISIBILITY_NOT_VISIBLE) {
147148
$visibleForStores = $this->visibleForStores->execute($product);
148149
if (count($visibleForStores) === 0 ||
150+
$product->getStoreId() !== Store::DEFAULT_STORE_ID &&
149151
!in_array($product->getStoreId(), $visibleForStores)
150152
) {
151153
return [];

app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/ProductUrlRewriteGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function testGenerateForDefaultNonVisible()
170170
$productMock->expects($this->once())
171171
->method('getVisibility')
172172
->willReturn(Product\Visibility::VISIBILITY_NOT_VISIBLE);
173-
$productMock->expects($this->exactly(2))
173+
$productMock->expects($this->exactly(3))
174174
->method('getStoreId')
175175
->willReturn($storeId);
176176
$productCategoriesMock = $this->getMockBuilder(Collection::class)

0 commit comments

Comments
 (0)