Skip to content

Commit 0d4ce63

Browse files
[Magento Community Engineering] Community Contributions - 2.4-develop-express-lane-prs
- merged with '2.4-develop-expedited-prs' branch
2 parents 0d5e7f8 + 40aef14 commit 0d4ce63

File tree

20 files changed

+1075
-35
lines changed

20 files changed

+1075
-35
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1-
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
2-
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
3-
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg)](https://crowdin.com/project/magento-2)
1+
<p align="center">
2+
<a href="https://magento.com">
3+
<img src="https://static.magento.com/sites/all/themes/magento/logo.svg" width="300px" alt="Magento" />
4+
</a>
5+
</p>
6+
<p align="center">
7+
<br /><br />
8+
<a href="https://www.codetriage.com/magento/magento2">
9+
<img src="https://www.codetriage.com/magento/magento2/badges/users.svg" alt="Open Source Helpers" />
10+
</a>
11+
<a href="https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge">
12+
<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Gitter" />
13+
</a>
14+
<a href="https://crowdin.com/project/magento-2">
15+
<img src="https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg" alt="Crowdin" />
16+
</a>
17+
</p>
418

519
## Welcome
620
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*/
66
namespace Magento\CatalogInventory\Model\Quote\Item\QuantityValidator;
77

8+
/**
9+
* Class QuoteItemQtyList collects qty of quote items
10+
*/
811
class QuoteItemQtyList
912
{
1013
/**
@@ -17,6 +20,7 @@ class QuoteItemQtyList
1720

1821
/**
1922
* Get product qty includes information from all quote items
23+
*
2024
* Need be used only in singleton mode
2125
*
2226
* @param int $productId
@@ -29,18 +33,18 @@ class QuoteItemQtyList
2933
public function getQty($productId, $quoteItemId, $quoteId, $itemQty)
3034
{
3135
$qty = $itemQty;
32-
if (isset(
33-
$this->_checkedQuoteItems[$quoteId][$productId]['qty']
34-
) && !in_array(
36+
if (isset($this->_checkedQuoteItems[$quoteId][$productId]['qty']) && !in_array(
3537
$quoteItemId,
3638
$this->_checkedQuoteItems[$quoteId][$productId]['items']
3739
)
3840
) {
3941
$qty += $this->_checkedQuoteItems[$quoteId][$productId]['qty'];
4042
}
4143

42-
$this->_checkedQuoteItems[$quoteId][$productId]['qty'] = $qty;
43-
$this->_checkedQuoteItems[$quoteId][$productId]['items'][] = $quoteItemId;
44+
if ($quoteItemId !== null) {
45+
$this->_checkedQuoteItems[$quoteId][$productId]['qty'] = $qty;
46+
$this->_checkedQuoteItems[$quoteId][$productId]['items'][] = $quoteItemId;
47+
}
4448

4549
return $qty;
4650
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\CatalogInventory\Test\Unit\Model\Quote\Item\QuantityValidator;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
use PHPUnit\Framework\TestCase;
11+
use Magento\CatalogInventory\Model\Quote\Item\QuantityValidator\QuoteItemQtyList;
12+
13+
/**
14+
* Class QuoteItemQtyListTest
15+
*
16+
* Test for QuoteItemQtyList class
17+
*/
18+
class QuoteItemQtyListTest extends TestCase
19+
{
20+
/**
21+
* @var QuoteItemQtyList
22+
*/
23+
private $quoteItemQtyList;
24+
25+
/**
26+
* @var int
27+
*/
28+
private $itemQtyTestValue;
29+
30+
/**
31+
* Sets up the fixture, for example, open a network connection.
32+
* This method is called before a test is executed.
33+
*/
34+
protected function setUp()
35+
{
36+
$objectManagerHelper = new ObjectManager($this);
37+
$this->quoteItemQtyList = $objectManagerHelper->getObject(QuoteItemQtyList::class);
38+
}
39+
40+
/**
41+
* This tests the scenario when item has not quote_item_id and after save gets a value.
42+
*
43+
* @return void
44+
*/
45+
public function testSingleQuoteItemQty()
46+
{
47+
$this->itemQtyTestValue = 1;
48+
$qty = $this->quoteItemQtyList->getQty(125, null, 11232, 1);
49+
$this->assertEquals($this->itemQtyTestValue, $qty);
50+
51+
$qty = $this->quoteItemQtyList->getQty(125, 1, 11232, 1);
52+
$this->assertEquals($this->itemQtyTestValue, $qty);
53+
}
54+
55+
/**
56+
* This tests the scenario when item has been added twice to the cart.
57+
*
58+
* @return void
59+
*/
60+
public function testMultipleQuoteItemQty()
61+
{
62+
$this->itemQtyTestValue = 1;
63+
$qty = $this->quoteItemQtyList->getQty(127, 1, 112, 1);
64+
$this->assertEquals($this->itemQtyTestValue, $qty);
65+
66+
$this->itemQtyTestValue = 2;
67+
$qty = $this->quoteItemQtyList->getQty(127, 2, 112, 1);
68+
$this->assertEquals($this->itemQtyTestValue, $qty);
69+
}
70+
}

app/code/Magento/ConfigurableProduct/Pricing/Render/TierPriceBox.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Responsible for displaying tier price box on configurable product page.
12-
*
13-
* @package Magento\ConfigurableProduct\Pricing\Render
1412
*/
1513
class TierPriceBox extends FinalPriceBox
1614
{
@@ -23,6 +21,7 @@ public function toHtml()
2321
if (!$this->isMsrpPriceApplicable() && $this->isTierPriceApplicable()) {
2422
return parent::toHtml();
2523
}
24+
return '';
2625
}
2726

2827
/**
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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\ConfigurableProduct\Test\Unit\Pricing\Render;
9+
10+
use Magento\Catalog\Model\Product;
11+
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
12+
use Magento\Catalog\Pricing\Price\MinimalPriceCalculatorInterface;
13+
use Magento\ConfigurableProduct\Pricing\Price\ConfigurableOptionsProviderInterface;
14+
use Magento\ConfigurableProduct\Pricing\Render\TierPriceBox;
15+
use Magento\Framework\Pricing\Price\PriceInterface;
16+
use Magento\Framework\Pricing\PriceInfoInterface;
17+
use Magento\Framework\Pricing\Render\RendererPool;
18+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
19+
use Magento\Framework\View\Element\Template\Context;
20+
use Magento\Msrp\Pricing\Price\MsrpPrice;
21+
use PHPUnit\Framework\MockObject\MockObject;
22+
23+
class TierPriceBoxTest extends \PHPUnit\Framework\TestCase
24+
{
25+
/**
26+
* @var Context|MockObject
27+
*/
28+
private $context;
29+
30+
/**
31+
* @var Product|MockObject
32+
*/
33+
private $saleableItem;
34+
35+
/**
36+
* @var PriceInterface|MockObject
37+
*/
38+
private $price;
39+
40+
/**
41+
* @var RendererPool|MockObject
42+
*/
43+
private $rendererPool;
44+
45+
/**
46+
* @var SalableResolverInterface|MockObject
47+
*/
48+
private $salableResolver;
49+
50+
/**
51+
* @var MinimalPriceCalculatorInterface|MockObject
52+
*/
53+
private $minimalPriceCalculator;
54+
55+
/**
56+
* @var ConfigurableOptionsProviderInterface|MockObject
57+
*/
58+
private $configurableOptionsProvider;
59+
60+
/**
61+
* @var TierPriceBox
62+
*/
63+
private $model;
64+
65+
/**
66+
* @inheritDoc
67+
*/
68+
protected function setUp(): void
69+
{
70+
$this->context = $this->createPartialMock(Context::class, []);
71+
$this->saleableItem = $this->createPartialMock(Product::class, ['getPriceInfo']);
72+
$this->price = $this->createMock(PriceInterface::class);
73+
$this->rendererPool = $this->createPartialMock(RendererPool::class, []);
74+
$this->salableResolver = $this->createPartialMock(SalableResolverInterface::class, ['isSalable']);
75+
$this->minimalPriceCalculator = $this->createMock(MinimalPriceCalculatorInterface::class);
76+
$this->configurableOptionsProvider = $this->createMock(ConfigurableOptionsProviderInterface::class);
77+
78+
$this->model = (new ObjectManager($this))->getObject(
79+
TierPriceBox::class,
80+
[
81+
'context' => $this->context,
82+
'saleableItem' => $this->saleableItem,
83+
'price' => $this->price,
84+
'rendererPool' => $this->rendererPool,
85+
'salableResolver' => $this->salableResolver,
86+
'minimalPriceCalculator' => $this->minimalPriceCalculator,
87+
'configurableOptionsProvider' => $this->configurableOptionsProvider,
88+
]
89+
);
90+
}
91+
92+
public function testToHtmlEmptyWhenMsrpPriceIsApplicable(): void
93+
{
94+
$msrpPriceMock = $this->createPartialMock(
95+
MsrpPrice::class,
96+
['canApplyMsrp', 'isMinimalPriceLessMsrp']
97+
);
98+
$msrpPriceMock->expects($this->once())
99+
->method('canApplyMsrp')
100+
->willReturn(true);
101+
$msrpPriceMock->expects($this->once())
102+
->method('isMinimalPriceLessMsrp')
103+
->willReturn(true);
104+
105+
$priceInfoMock = $this->createMock(PriceInfoInterface::class);
106+
$priceInfoMock->expects($this->once())
107+
->method('getPrice')
108+
->willReturn($msrpPriceMock);
109+
110+
$this->saleableItem->expects($this->once())
111+
->method('getPriceInfo')
112+
->willReturn($priceInfoMock);
113+
114+
$result = $this->model->toHtml();
115+
$this->assertSame('', $result);
116+
}
117+
}

app/code/Magento/Eav/Model/Entity/Collection/AbstractCollection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
abstract class AbstractCollection extends AbstractDb implements SourceProviderInterface
2525
{
2626
/**
27-
* Attribute table alias prefix
27+
* Define default prefix for attribute table alias
2828
*/
2929
const ATTRIBUTE_TABLE_ALIAS_PREFIX = 'at_';
3030

@@ -495,7 +495,7 @@ public function addAttributeToSelect($attribute, $joinType = false)
495495
$entity = clone $this->getEntity();
496496
$attributes = $entity->loadAllAttributes()->getAttributesByCode();
497497
foreach ($attributes as $attrCode => $attr) {
498-
$this->_selectAttributes[$attrCode] = $attr->getId();
498+
$this->_selectAttributes[$attrCode] = (int) $attr->getId();
499499
}
500500
} else {
501501
if (isset($this->_joinAttributes[$attribute])) {
@@ -511,7 +511,7 @@ public function addAttributeToSelect($attribute, $joinType = false)
511511
)
512512
);
513513
}
514-
$this->_selectAttributes[$attrInstance->getAttributeCode()] = $attrInstance->getId();
514+
$this->_selectAttributes[$attrInstance->getAttributeCode()] = (int) $attrInstance->getId();
515515
}
516516
return $this;
517517
}
@@ -1173,7 +1173,7 @@ public function _loadAttributes($printQuery = false, $logQuery = false)
11731173
}
11741174
$attribute = $this->_eavConfig->getAttribute($entity->getType(), $attributeCode);
11751175
if ($attribute && !$attribute->isStatic()) {
1176-
$tableAttributes[$attribute->getBackendTable()][] = $attributeId;
1176+
$tableAttributes[$attribute->getBackendTable()][] = (int) $attributeId;
11771177
if (!isset($attributeTypes[$attribute->getBackendTable()])) {
11781178
$attributeTypes[$attribute->getBackendTable()] = $attribute->getBackendType();
11791179
}

app/code/Magento/Eav/Test/Unit/Model/Entity/Collection/AbstractCollectionStub.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,14 @@ protected function _construct()
3030
{
3131
return $this->_init(\Magento\Framework\DataObject::class, 'test_entity_model');
3232
}
33+
34+
/**
35+
* Retrieve collection empty item
36+
*
37+
* @return \Magento\Framework\DataObject
38+
*/
39+
public function getNewEmptyItem()
40+
{
41+
return new \Magento\Framework\DataObject();
42+
}
3343
}

0 commit comments

Comments
 (0)