Skip to content

Commit 193b778

Browse files
author
Robert He
committed
MAGETWO-55682: Backport ticket https://jira.corp.magento.com/browse/MAGETWO-55514 to 2.0.11
- backport changes
1 parent f0d9099 commit 193b778

File tree

2 files changed

+35
-8
lines changed

2 files changed

+35
-8
lines changed

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ public function showMinimalPrice()
119119
&& $minimalPriceAValue < $finalPriceValue;
120120
}
121121

122+
/**
123+
* Get Key for caching block content
124+
*
125+
* @return string
126+
*/
127+
public function getCacheKey()
128+
{
129+
return parent::getCacheKey() . ($this->getData('list_category_page') ? '-list-category-page': '');
130+
}
131+
122132
/**
123133
* {@inheritdoc}
124134
*

app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,27 @@ protected function setUp()
8181
->method('getBlock')
8282
->will($this->returnValue($this->priceBox));
8383

84-
$storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface')
85-
->setMethods(['getStore', 'getCode'])
84+
$cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class)
8685
->getMockForAbstractClass();
87-
$storeManager->expects($this->any())->method('getStore')->willReturnSelf();
8886

89-
$appState = $this->getMockBuilder('\Magento\Framework\App\State')
87+
$appState = $this->getMockBuilder(\Magento\Framework\App\State::class)
9088
->disableOriginalConstructor()
9189
->getMock();
9290

93-
$resolver = $this->getMockBuilder('\Magento\Framework\View\Element\Template\File\Resolver')
91+
$resolver = $this->getMockBuilder(\Magento\Framework\View\Element\Template\File\Resolver::class)
9492
->disableOriginalConstructor()
9593
->getMock();
9694

97-
$urlBuilder = $this->getMockBuilder('\Magento\Framework\UrlInterface')
95+
$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
96+
->getMockForAbstractClass();
97+
98+
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
99+
->getMockForAbstractClass();
100+
101+
$storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface')
102+
->setMethods(['getStore', 'getCode'])
98103
->getMockForAbstractClass();
104+
$storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store));
99105

100106
$scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface');
101107
$context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false);
@@ -114,6 +120,9 @@ protected function setUp()
114120
$context->expects($this->any())
115121
->method('getScopeConfig')
116122
->will($this->returnValue($scopeConfigMock));
123+
$context->expects($this->any())
124+
->method('getCacheState')
125+
->will($this->returnValue($cacheState));
117126
$context->expects($this->any())
118127
->method('getStoreManager')
119128
->will($this->returnValue($storeManager));
@@ -124,7 +133,8 @@ protected function setUp()
124133
->method('getResolver')
125134
->will($this->returnValue($resolver));
126135
$context->expects($this->any())
127-
->method('getUrlBuilder')->will($this->returnValue($urlBuilder));
136+
->method('getUrlBuilder')
137+
->will($this->returnValue($urlBuilder));
128138

129139
$this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool')
130140
->disableOriginalConstructor()
@@ -143,7 +153,7 @@ protected function setUp()
143153
'saleableItem' => $this->product,
144154
'rendererPool' => $this->rendererPool,
145155
'price' => $this->price,
146-
'data' => ['zone' => 'test_zone']
156+
'data' => ['zone' => 'test_zone', 'list_category_page' => true]
147157
]
148158
);
149159
}
@@ -240,6 +250,7 @@ public function testRenderAmountMinimal()
240250

241251
$arguments = [
242252
'zone' => 'test_zone',
253+
'list_category_page' => true,
243254
'display_label' => 'As low as',
244255
'price_id' => $priceId,
245256
'include_container' => false,
@@ -360,6 +371,12 @@ public function testHidePrice()
360371
$this->assertEmpty($this->object->toHtml());
361372
}
362373

374+
public function testGetCacheKey()
375+
{
376+
$result = $this->object->getCacheKey();
377+
$this->assertStringEndsWith('list-category-page', $result);
378+
}
379+
363380
public function testGetCacheKeyInfo()
364381
{
365382
$this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo());

0 commit comments

Comments
 (0)