Skip to content

Commit

Permalink
Merge pull request #6502 from magento-tsg-csl3/2.4-develop-pr49
Browse files Browse the repository at this point in the history
[TSG-CSL3] For 2.4 (pr49)
  • Loading branch information
zakdma authored Jan 8, 2021
2 parents 6f79389 + 15bd50d commit 63434d2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 10 deletions.
8 changes: 7 additions & 1 deletion app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Magento\Bundle\Model\Product\Type;
use Magento\Bundle\Model\ResourceModel\BundleFactory;
use Magento\Bundle\Model\ResourceModel\Option\Collection;
use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor;
use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection;
use Magento\Bundle\Model\ResourceModel\Selection\CollectionFactory;
use Magento\Bundle\Model\Selection;
Expand All @@ -28,6 +27,7 @@
use Magento\CatalogInventory\Api\StockStateInterface;
use Magento\CatalogInventory\Model\StockRegistry;
use Magento\CatalogInventory\Model\StockState;
use Magento\CatalogRule\Model\ResourceModel\Product\CollectionProcessor;
use Magento\Framework\DataObject;
use Magento\Framework\EntityManager\EntityMetadataInterface;
use Magento\Framework\EntityManager\MetadataPool;
Expand Down Expand Up @@ -1548,6 +1548,10 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
->disableOriginalConstructor()
->getMock();

$buyRequest->method('getOptions')
->willReturn([333 => ['type' => 'image/jpeg']]);
$option->method('getId')
->willReturn(333);
$this->parentClass($group, $option, $buyRequest, $product);

$product->expects($this->any())
Expand All @@ -1556,6 +1560,8 @@ public function testPrepareForCartAdvancedSpecifyProductOptions()
$buyRequest->expects($this->once())
->method('getBundleOption')
->willReturn([0, '', 'str']);
$group->expects($this->once())
->method('validateUserValue');

$result = $this->model->prepareForCartAdvanced($buyRequest, $product);
$this->assertEquals('Please specify product option(s).', $result);
Expand Down
7 changes: 5 additions & 2 deletions app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Catalog\Model\Product\Type;

Expand Down Expand Up @@ -605,7 +604,11 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p
if ($product->getSkipCheckRequiredOption() !== true) {
$group->validateUserValue($optionsFromRequest);
} elseif ($optionsFromRequest !== null && isset($optionsFromRequest[$option->getId()])) {
$transport->options[$option->getId()] = $optionsFromRequest[$option->getId()];
if (is_array($optionsFromRequest[$option->getId()])) {
$group->validateUserValue($optionsFromRequest);
} else {
$transport->options[$option->getId()] = $optionsFromRequest[$option->getId()];
}
}

} catch (LocalizedException $e) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Sales/Model/RtlTextHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function reverseRtlText(string $string): string

for ($i = 0; $i < $splitTextAmount; $i++) {
if ($this->isRtlText($splitText[$i])) {
for ($j = $i + 1; $j < $splitTextAmount; $j++) {
for ($j = $i; $j < $splitTextAmount; $j++) {
$tmp = $this->isRtlText($splitText[$j])
? $this->stringUtils->strrev($splitText[$j]) : $splitText[$j];
$splitText[$j] = $this->isRtlText($splitText[$i])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function provideRtlTexts(): array
['Herr Prof. Dr. Gerald Schüler B.A.', false],//German
['نديم مقداد نعمان القحطاني', true],//Arabic
['شهاب الفرحان', true],//Arabic
['مرحبا ماجنت اثنان', true],//Arabic
['צבר קרליבך', true],//Hebrew
['גורי מייזליש', true],//Hebrew
['اتابک بهشتی', true],//Persian
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* Contains tests for Price class
*/
class PriceTest extends TestCase
{
/**
Expand All @@ -34,6 +37,9 @@ class PriceTest extends TestCase
*/
private $storeManagerMock;

/**
* @inheritDoc
*/
protected function setUp(): void
{
$objectManager = new ObjectManager($this);
Expand All @@ -57,12 +63,20 @@ protected function setUp(): void
}

/**
* @param $hasCurrency
* @param $dataSource
* @param $currencyCode
* Test for prepareDataSource method
*
* @param bool $hasCurrency
* @param array $dataSource
* @param string $currencyCode
* @param int|null $expectedStoreId
* @dataProvider testPrepareDataSourceDataProvider
*/
public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode)
public function testPrepareDataSource(
bool $hasCurrency,
array $dataSource,
string $currencyCode,
?int $expectedStoreId = null
): void
{
$itemName = 'itemName';
$oldItemValue = 'oldItemValue';
Expand All @@ -79,6 +93,7 @@ public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode)
->willReturn($currencyCode);
$this->storeManagerMock->expects($hasCurrency ? $this->never() : $this->once())
->method('getStore')
->with($expectedStoreId)
->willReturn($store);
$store->expects($hasCurrency ? $this->never() : $this->once())
->method('getBaseCurrency')
Expand All @@ -98,7 +113,12 @@ public function testPrepareDataSource($hasCurrency, $dataSource, $currencyCode)
$this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
}

public function testPrepareDataSourceDataProvider()
/**
* Provider for testPrepareDataSource
*
* @return array
*/
public function testPrepareDataSourceDataProvider(): array
{
$dataSource1 = [
'data' => [
Expand All @@ -119,9 +139,31 @@ public function testPrepareDataSourceDataProvider()
]
]
];
$dataSource3 = [
'data' => [
'items' => [
[
'itemName' => 'oldItemValue',
'store_id' => '2'
]
]
]
];
$dataSource4 = [
'data' => [
'items' => [
[
'itemName' => 'oldItemValue',
'store_id' => 'abc'
]
]
]
];
return [
[true, $dataSource1, 'US'],
[false, $dataSource2, 'SAR'],
[false, $dataSource3, 'SAR', 2],
[false, $dataSource4, 'SAR'],
];
}
}
5 changes: 4 additions & 1 deletion app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\Pricing\PriceCurrencyInterface;
Expand Down Expand Up @@ -77,8 +78,10 @@ public function prepareDataSource(array $dataSource)
foreach ($dataSource['data']['items'] as & $item) {
$currencyCode = isset($item['base_currency_code']) ? $item['base_currency_code'] : null;
if (!$currencyCode) {
$storeId = isset($item['store_id']) && (int)$item['store_id'] !== 0 ? $item['store_id'] :
$this->context->getFilterParam('store_id', Store::DEFAULT_STORE_ID);
$store = $this->storeManager->getStore(
$this->context->getFilterParam('store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
$storeId
);
$currencyCode = $store->getBaseCurrency()->getCurrencyCode();
}
Expand Down

0 comments on commit 63434d2

Please sign in to comment.