diff --git a/app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php b/app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php index 6d8e4bcd2fd1c..be995258794cc 100644 --- a/app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php +++ b/app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php @@ -21,15 +21,12 @@ class ConfigurableProduct extends FinalPrice implements ConfiguredPriceInterface */ public function getValue() { - $result = 0.; /** @var \Magento\Wishlist\Model\Item\Option $customOption */ $customOption = $this->getProduct()->getCustomOption('simple_product'); - if ($customOption) { - /** @var \Magento\Framework\Pricing\PriceInfoInterface $priceInfo */ - $priceInfo = $customOption->getProduct()->getPriceInfo(); - $result = $priceInfo->getPrice(self::PRICE_CODE)->getValue(); - } - return max(0, $result); + $product = $customOption ? $customOption->getProduct() : $this->getProduct(); + $price = $product->getPriceInfo()->getPrice(self::PRICE_CODE)->getValue(); + + return max(0, $price); } /** diff --git a/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php b/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php index 9e05a578080ef..ca66625bad5ee 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php @@ -49,9 +49,6 @@ protected function setUp() 'getCustomOption', ]) ->getMockForAbstractClass(); - $this->saleableItem->expects($this->once()) - ->method('getPriceInfo') - ->willReturn($this->priceInfoMock); $this->calculator = $this->getMockBuilder(\Magento\Framework\Pricing\Adjustment\CalculatorInterface::class) ->getMockForAbstractClass(); @@ -109,11 +106,28 @@ public function testGetValue() public function testGetValueWithNoCustomOption() { + $priceValue = 100; + + $priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class) + ->getMockForAbstractClass(); + $priceMock->expects($this->once()) + ->method('getValue') + ->willReturn($priceValue); + $this->saleableItem->expects($this->once()) ->method('getCustomOption') ->with('simple_product') ->willReturn(null); - $this->assertEquals(0, $this->model->getValue()); + $this->saleableItem->expects($this->once()) + ->method('getPriceInfo') + ->willReturn($this->priceInfoMock); + + $this->priceInfoMock->expects($this->once()) + ->method('getPrice') + ->with(ConfigurableProduct::PRICE_CODE) + ->willReturn($priceMock); + + $this->assertEquals(100, $this->model->getValue()); } }