Skip to content

Commit

Permalink
MAGETWO-59512: [GitHub] Products in wishlist show $0.00 price magento…
Browse files Browse the repository at this point in the history
  • Loading branch information
Stanislav Idolov committed Oct 20, 2016
1 parent 730b984 commit c7d18bd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
}
}

0 comments on commit c7d18bd

Please sign in to comment.