From a816eb26be4136fdecf37993d3a226dd12cd2be9 Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Wed, 6 Jun 2018 17:29:47 +0300 Subject: [PATCH] Adjust the cache key for product price box renderer in order to fix the cache issue for currencies with no symbol --- .../Block/Category/Plugin/PriceBoxTags.php | 2 +- .../Block/Category/Plugin/PriceBoxTagsTest.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Category/Plugin/PriceBoxTags.php b/app/code/Magento/Catalog/Block/Category/Plugin/PriceBoxTags.php index b6ad1c605ab7a..c87f2b7233f3b 100644 --- a/app/code/Magento/Catalog/Block/Category/Plugin/PriceBoxTags.php +++ b/app/code/Magento/Catalog/Block/Category/Plugin/PriceBoxTags.php @@ -71,7 +71,7 @@ public function afterGetCacheKey(PriceBox $subject, $result) '-', [ $result, - $this->priceCurrency->getCurrencySymbol(), + $this->priceCurrency->getCurrency()->getCode(), $this->dateTime->scopeDate($this->scopeResolver->getScope()->getId())->format('Ymd'), $this->scopeResolver->getScope()->getId(), $this->customerSession->getCustomerGroupId(), diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php index 424d68b6e3626..eb59bbc7091ca 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Category/Plugin/PriceBoxTagsTest.php @@ -16,6 +16,11 @@ class PriceBoxTagsTest extends \PHPUnit_Framework_TestCase */ private $priceCurrencyInterface; + /** + * @var \Magento\Directory\Model\Currency | \PHPUnit_Framework_MockObject_MockObject + */ + private $currency; + /** * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface | \PHPUnit_Framework_MockObject_MockObject */ @@ -46,6 +51,9 @@ protected function setUp() $this->priceCurrencyInterface = $this->getMockBuilder( \Magento\Framework\Pricing\PriceCurrencyInterface::class )->getMock(); + $this->currency = $this->getMockBuilder(\Magento\Directory\Model\Currency::class) + ->disableOriginalConstructor() + ->getMock(); $this->timezoneInterface = $this->getMockBuilder( \Magento\Framework\Stdlib\DateTime\TimezoneInterface::class )->getMock(); @@ -82,7 +90,7 @@ protected function setUp() public function testAfterGetCacheKey() { $date = date('Ymd'); - $currencySymbol = '$'; + $currencyCode = 'USD'; $result = 'result_string'; $billingAddress = ['billing_address']; $shippingAddress = ['shipping_address']; @@ -95,7 +103,7 @@ public function testAfterGetCacheKey() '-', [ $result, - $currencySymbol, + $currencyCode, $date, $scopeId, $customerGroupId, @@ -104,7 +112,8 @@ public function testAfterGetCacheKey() ); $priceBox = $this->getMockBuilder(\Magento\Framework\Pricing\Render\PriceBox::class) ->disableOriginalConstructor()->getMock(); - $this->priceCurrencyInterface->expects($this->once())->method('getCurrencySymbol')->willReturn($currencySymbol); + $this->priceCurrencyInterface->expects($this->once())->method('getCurrency')->willReturn($this->currency); + $this->currency->expects($this->once())->method('getCode')->willReturn($currencyCode); $scope = $this->getMockBuilder(\Magento\Framework\App\ScopeInterface::class)->getMock(); $this->scopeResolverInterface->expects($this->any())->method('getScope')->willReturn($scope); $scope->expects($this->any())->method('getId')->willReturn($scopeId);