Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function getCacheKeyInfo()

return [
'CATALOG_PRODUCTS_LIST_WIDGET',
$this->priceCurrency->getCurrencySymbol(),
$this->priceCurrency->getCurrency()->getCode(),
$this->_storeManager->getStore()->getId(),
$this->_design->getDesignTheme()->getId(),
$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,17 @@ class ProductsListTest extends \PHPUnit_Framework_TestCase
*/
private $priceCurrency;

/**
* @var \Magento\Directory\Model\Currency|\PHPUnit_Framework_MockObject_MockObject
*/
private $currency;

protected function setUp()
{
$this->priceCurrency = $this->getMock(PriceCurrencyInterface::class);
$this->currency = $this->getMockBuilder(\Magento\Directory\Model\Currency::class)
->disableOriginalConstructor()
->getMock();
$this->collectionFactory =
$this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory::class)
->setMethods(['create'])
Expand Down Expand Up @@ -122,6 +130,7 @@ protected function setUp()

public function testGetCacheKeyInfo()
{
$currencyCode = 'USD';
$store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
->disableOriginalConstructor()->setMethods(['getId'])->getMock();
$store->expects($this->once())->method('getId')->willReturn(1);
Expand All @@ -136,11 +145,12 @@ public function testGetCacheKeyInfo()
$this->productsList->setData('page_var_name', 'page_number');
$this->request->expects($this->once())->method('getParam')->with('page_number')->willReturn(1);
$this->request->expects($this->once())->method('getParams')->willReturn('request_params');
$this->priceCurrency->expects($this->once())->method('getCurrencySymbol')->willReturn('$');
$this->priceCurrency->expects($this->once())->method('getCurrency')->willReturn($this->currency);
$this->currency->expects($this->once())->method('getCode')->willReturn($currencyCode);

$cacheKey = [
'CATALOG_PRODUCTS_LIST_WIDGET',
'$',
$currencyCode,
1,
'blank',
'context_group',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function __construct(
public function getCacheKeyInfo()
{
$parentData = parent::getCacheKeyInfo();
$parentData[] = $this->priceCurrency->getCurrencySymbol();
$parentData[] = $this->priceCurrency->getCurrency()->getCode();
return $parentData;
}

Expand Down