From 292c560070037f280d9953af7966af7d1acaf890 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi Date: Tue, 22 Dec 2020 13:54:39 +0200 Subject: [PATCH 1/4] =?UTF-8?q?MC-39809:=20A=20Product=20with=20Customizab?= =?UTF-8?q?le=20Option=20(File)=20can=20not=20be=20added=20by=20Admin=20fr?= =?UTF-8?q?om=20the=20=E2=80=9CShopping=20Cart=20section=20(=E2=80=9CCusto?= =?UTF-8?q?mer's=20Activities=E2=80=9D=20column)=20to=20Order?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Magento/Bundle/Test/Unit/Model/Product/TypeTest.php | 8 +++++++- .../Magento/Catalog/Model/Product/Type/AbstractType.php | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php index b7041051591d8..9c4d4ce00b7c0 100644 --- a/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Model/Product/TypeTest.php @@ -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; @@ -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; @@ -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()) @@ -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); diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php index f90b097415661..19f6461d44b6a 100644 --- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php +++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php @@ -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; @@ -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) { From bd329b681eeab9b667f2fcbe4a1aa67d23d4b3e3 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi Date: Wed, 30 Dec 2020 14:46:51 +0200 Subject: [PATCH 2/4] MC-40030: Wrong currency sign in Credit Memo grid with Website scope for Price --- app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php b/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php index 4ffb6f98447c7..cc323730f14b4 100644 --- a/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php +++ b/app/code/Magento/Sales/Ui/Component/Listing/Column/Price.php @@ -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; @@ -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(); } From 10272105edddaca5363e1e16ea033184b33dd009 Mon Sep 17 00:00:00 2001 From: Vasya Tsviklinskyi Date: Thu, 31 Dec 2020 09:47:11 +0200 Subject: [PATCH 3/4] MC-40030: Wrong currency sign in Credit Memo grid with Website scope for Price --- .../Ui/Component/Listing/Column/PriceTest.php | 52 +++++++++++++++++-- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php index 4a9061c3f3c5c..449ab230b568d 100644 --- a/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php +++ b/app/code/Magento/Sales/Test/Unit/Ui/Component/Listing/Column/PriceTest.php @@ -17,6 +17,9 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; +/** + * Contains tests for Price class + */ class PriceTest extends TestCase { /** @@ -34,6 +37,9 @@ class PriceTest extends TestCase */ private $storeManagerMock; + /** + * @inheritDoc + */ protected function setUp(): void { $objectManager = new ObjectManager($this); @@ -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'; @@ -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') @@ -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' => [ @@ -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'], ]; } } From 6db8da7e8d8e5d0df516b501cf2473b43fcc4c8b Mon Sep 17 00:00:00 2001 From: Nikita Shcherbatykh Date: Wed, 6 Jan 2021 10:18:37 +0200 Subject: [PATCH 4/4] MC-39891: Arabic text in invoice is not displayed correctly --- app/code/Magento/Sales/Model/RtlTextHandler.php | 2 +- app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Sales/Model/RtlTextHandler.php b/app/code/Magento/Sales/Model/RtlTextHandler.php index cfb88dc63f58b..b943320e0f897 100644 --- a/app/code/Magento/Sales/Model/RtlTextHandler.php +++ b/app/code/Magento/Sales/Model/RtlTextHandler.php @@ -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]) diff --git a/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php b/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php index 2faeb17dc2395..1a8159dbf4cbb 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/RtlTextHandlerTest.php @@ -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