From 6ab22bc71e9493af8fe13a0b0c9f510c7ab0de8b Mon Sep 17 00:00:00 2001
From: Mykola Palamar <mpalamar@magento.com>
Date: Tue, 12 Jul 2016 20:51:11 +0300
Subject: [PATCH] MAGETWO-55055: [Github #5364] Tier price doesn't work
 correctly with FPC

---
 .../Catalog/Pricing/Render/FinalPriceBox.php  | 12 +++++++
 .../Unit/Pricing/Render/FinalPriceBoxTest.php | 33 +++++++++++++++++++
 2 files changed, 45 insertions(+)

diff --git a/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php b/app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
index 5ab2484348b..5ea65f2ca60 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 859f510024b..c5e90e27658 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());
+    }
 }
-- 
GitLab