Skip to content

Commit 63434d2

Browse files
authored
Merge pull request #6502 from magento-tsg-csl3/2.4-develop-pr49
[TSG-CSL3] For 2.4 (pr49)
2 parents 6f79389 + 15bd50d commit 63434d2

File tree

6 files changed

+65
-10
lines changed

6 files changed

+65
-10
lines changed

app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\Bundle\Model\Product\Type;
1212
use Magento\Bundle\Model\ResourceModel\BundleFactory;
1313
use Magento\Bundle\Model\ResourceModel\Option\Collection;
14-
use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor;
1514
use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection;
1615
use Magento\Bundle\Model\ResourceModel\Selection\CollectionFactory;
1716
use Magento\Bundle\Model\Selection;
@@ -28,6 +27,7 @@
2827
use Magento\CatalogInventory\Api\StockStateInterface;
2928
use Magento\CatalogInventory\Model\StockRegistry;
3029
use Magento\CatalogInventory\Model\StockState;
30+
use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor;
3131
use Magento\Framework\DataObject;
3232
use Magento\Framework\EntityManager\EntityMetadataInterface;
3333
use Magento\Framework\EntityManager\MetadataPool;
@@ -1548,6 +1548,10 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
15481548
->disableOriginalConstructor()
15491549
->getMock();
15501550

1551+
$buyRequest->method('getOptions')
1552+
->willReturn([333 => ['type' => 'image/jpeg']]);
1553+
$option->method('getId')
1554+
->willReturn(333);
15511555
$this->parentClass($group, $option, $buyRequest, $product);
15521556

15531557
$product->expects($this->any())
@@ -1556,6 +1560,8 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
15561560
$buyRequest->expects($this->once())
15571561
->method('getBundleOption')
15581562
->willReturn([0, '', 'str']);
1563+
$group->expects($this->once())
1564+
->method('validateUserValue');
15591565

15601566
$result = $this->model->prepareForCartAdvanced($buyRequest, $product);
15611567
$this->assertEquals('Please specify product option(s).', $result);

app/code/Magento/Catalog/Model/Product/Type/AbstractType.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
declare(strict_types=1);
76

87
namespace Magento\Catalog\Model\Product\Type;
98

@@ -605,7 +604,11 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p
605604
if ($product->getSkipCheckRequiredOption() !== true) {
606605
$group->validateUserValue($optionsFromRequest);
607606
} elseif ($optionsFromRequest !== null && isset($optionsFromRequest[$option->getId()])) {
608-
$transport->options[$option->getId()] = $optionsFromRequest[$option->getId()];
607+
if (is_array($optionsFromRequest[$option->getId()])) {
608+
$group->validateUserValue($optionsFromRequest);
609+
} else {
610+
$transport->options[$option->getId()] = $optionsFromRequest[$option->getId()];
611+
}
609612
}
610613

611614
} catch (LocalizedException $e) {

app/code/Magento/Sales/Model/RtlTextHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function reverseRtlText(string $string): string
4848

4949
for ($i = 0; $i < $splitTextAmount; $i++) {
5050
if ($this->isRtlText($splitText[$i])) {
51-
for ($j = $i + 1; $j < $splitTextAmount; $j++) {
51+
for ($j = $i; $j < $splitTextAmount; $j++) {
5252
$tmp = $this->isRtlText($splitText[$j])
5353
? $this->stringUtils->strrev($splitText[$j]) : $splitText[$j];
5454
$splitText[$j] = $this->isRtlText($splitText[$i])

app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public function provideRtlTexts(): array
6262
['Herr Prof. Dr. Gerald Schüler B.A.', false],//German
6363
['نديم مقداد نعمان القحطاني', true],//Arabic
6464
['شهاب الفرحان', true],//Arabic
65+
['مرحبا ماجنت اثنان', true],//Arabic
6566
['צבר קרליבך', true],//Hebrew
6667
['גורי מייזליש', true],//Hebrew
6768
['اتابک بهشتی', true],//Persian

app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php

+47-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use PHPUnit\Framework\MockObject\MockObject;
1818
use PHPUnit\Framework\TestCase;
1919

20+
/**
21+
* Contains tests for Price class
22+
*/
2023
class PriceTest extends TestCase
2124
{
2225
/**
@@ -34,6 +37,9 @@ class PriceTest extends TestCase
3437
*/
3538
private $storeManagerMock;
3639

40+
/**
41+
* @inheritDoc
42+
*/
3743
protected function setUp(): void
3844
{
3945
$objectManager = new ObjectManager($this);
@@ -57,12 +63,20 @@ protected function setUp(): void
5763
}
5864

5965
/**
60-
* @param $hasCurrency
61-
* @param $dataSource
62-
* @param $currencyCode
66+
* Test for prepareDataSource method
67+
*
68+
* @param bool $hasCurrency
69+
* @param array $dataSource
70+
* @param string $currencyCode
71+
* @param int|null $expectedStoreId
6372
* @dataProvider testPrepareDataSourceDataProvider
6473
*/
65-
public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode)
74+
public function testPrepareDataSource(
75+
bool $hasCurrency,
76+
array $dataSource,
77+
string $currencyCode,
78+
?int $expectedStoreId = null
79+
): void
6680
{
6781
$itemName = 'itemName';
6882
$oldItemValue = 'oldItemValue';
@@ -79,6 +93,7 @@ public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode)
7993
->willReturn($currencyCode);
8094
$this->storeManagerMock->expects($hasCurrency ? $this->never() : $this->once())
8195
->method('getStore')
96+
->with($expectedStoreId)
8297
->willReturn($store);
8398
$store->expects($hasCurrency ? $this->never() : $this->once())
8499
->method('getBaseCurrency')
@@ -98,7 +113,12 @@ public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode)
98113
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
99114
}
100115

101-
public function testPrepareDataSourceDataProvider()
116+
/**
117+
* Provider for testPrepareDataSource
118+
*
119+
* @return array
120+
*/
121+
public function testPrepareDataSourceDataProvider(): array
102122
{
103123
$dataSource1 = [
104124
'data' => [
@@ -119,9 +139,31 @@ public function testPrepareDataSourceDataProvider()
119139
]
120140
]
121141
];
142+
$dataSource3 = [
143+
'data' => [
144+
'items' => [
145+
[
146+
'itemName' => 'oldItemValue',
147+
'store_id' => '2'
148+
]
149+
]
150+
]
151+
];
152+
$dataSource4 = [
153+
'data' => [
154+
'items' => [
155+
[
156+
'itemName' => 'oldItemValue',
157+
'store_id' => 'abc'
158+
]
159+
]
160+
]
161+
];
122162
return [
123163
[true, $dataSource1, 'US'],
124164
[false, $dataSource2, 'SAR'],
165+
[false, $dataSource3, 'SAR', 2],
166+
[false, $dataSource4, 'SAR'],
125167
];
126168
}
127169
}

app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\ObjectManager;
1111
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1212
use Magento\Framework\View\Element\UiComponentFactory;
13+
use Magento\Store\Model\Store;
1314
use Magento\Store\Model\StoreManagerInterface;
1415
use Magento\Ui\Component\Listing\Columns\Column;
1516
use Magento\Framework\Pricing\PriceCurrencyInterface;
@@ -77,8 +78,10 @@ public function prepareDataSource(array $dataSource)
7778
foreach ($dataSource['data']['items'] as & $item) {
7879
$currencyCode = isset($item['base_currency_code']) ? $item['base_currency_code'] : null;
7980
if (!$currencyCode) {
81+
$storeId = isset($item['store_id']) && (int)$item['store_id'] !== 0 ? $item['store_id'] :
82+
$this->context->getFilterParam('store_id', Store::DEFAULT_STORE_ID);
8083
$store = $this->storeManager->getStore(
81-
$this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
84+
$storeId
8285
);
8386
$currencyCode = $store->getBaseCurrency()->getCurrencyCode();
8487
}

0 commit comments

Comments
 (0)