Skip to content

Commit

Permalink
Adjust the cache key for product price box renderer in order to fix t…
Browse files Browse the repository at this point in the history
…he cache issue for currencies with no symbol
  • Loading branch information
dmytro-ch committed Jun 6, 2018
1 parent c62d922 commit 23d76ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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'];
Expand All @@ -95,7 +103,7 @@ public function testAfterGetCacheKey()
'-',
[
$result,
$currencySymbol,
$currencyCode,
$date,
$scopeId,
$customerGroupId,
Expand All @@ -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);
Expand Down

0 comments on commit 23d76ed

Please sign in to comment.