diff --git a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php index 5ab2484348b0c05420cbef28713ed7385f01fa7e..5ea65f2ca608d7d744029a2ff54b8a9df2ac0ff5 100644 --- a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php +++ b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php @@ -118,4 +118,16 @@ class FinalPriceBox extends BasePriceBox && $minimalPriceAValue && $minimalPriceAValue < $finalPriceValue; } + + /** + * {@inheritdoc} + * + * @return array + */ + public function getCacheKeyInfo() + { + $cacheKeys = parent::getCacheKeyInfo(); + $cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice(); + return $cacheKeys; + } } diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php index 859f510024b8194b9b6c4b516f2084313eafc490..c5e90e27658ff8b8625394987c1954b775537437 100644 --- a/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Render/FinalPriceBoxTest.php @@ -84,6 +84,22 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase $cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class) ->getMockForAbstractClass(); + $storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface') + ->setMethods(['getStore', 'getCode']) + ->getMockForAbstractClass(); + $storeManager->expects($this->any())->method('getStore')->willReturnSelf(); + + $appState = $this->getMockBuilder('\Magento\Framework\App\State') + ->disableOriginalConstructor() + ->getMock(); + + $resolver = $this->getMockBuilder('\Magento\Framework\View\Element\Template\File\Resolver') + ->disableOriginalConstructor() + ->getMock(); + + $urlBuilder = $this->getMockBuilder('\Magento\Framework\UrlInterface') + ->getMockForAbstractClass(); + $scopeConfigMock = $this->getMockForAbstractClass('Magento\Framework\App\Config\ScopeConfigInterface'); $context = $this->getMock('Magento\Framework\View\Element\Template\Context', [], [], '', false); $context->expects($this->any()) @@ -104,6 +120,18 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase $context->expects($this->any()) ->method('getCacheState') ->will($this->returnValue($cacheState)); + $context->expects($this->any()) + ->method('getStoreManager') + ->will($this->returnValue($storeManager)); + $context->expects($this->any()) + ->method('getAppState') + ->will($this->returnValue($appState)); + $context->expects($this->any()) + ->method('getResolver') + ->will($this->returnValue($resolver)); + $context->expects($this->any()) + ->method('getUrlBuilder') + ->will($this->returnValue($urlBuilder)); $this->rendererPool = $this->getMockBuilder('Magento\Framework\Pricing\Render\RendererPool') ->disableOriginalConstructor() @@ -338,4 +366,9 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase $this->assertEmpty($this->object->toHtml()); } + + public function testGetCacheKeyInfo() + { + $this->assertArrayHasKey('display_minimal_price', $this->object->getCacheKeyInfo()); + } }