diff --git a/app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php b/app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php
index 77b0a042191bd..8cc8d62fd2aa7 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 6545326ef5a57..2b74df28e5cdf 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php
@@ -5,36 +5,30 @@
*/
namespace Magento\Wishlist\Test\Unit\Pricing\ConfiguredPrice;
-use Magento\Framework\Pricing\Adjustment\CalculatorInterface;
-use Magento\Framework\Pricing\PriceCurrencyInterface;
-use Magento\Framework\Pricing\PriceInfoInterface;
-use Magento\Framework\Pricing\SaleableInterface;
-use Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct;
-
class ConfigurableProductTest extends \PHPUnit_Framework_TestCase
{
/**
- * @var SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Pricing\SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $saleableItem;
/**
- * @var CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Pricing\Adjustment\CalculatorInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $calculator;
/**
- * @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Pricing\PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $priceCurrency;
/**
- * @var ConfigurableProduct
+ * @var \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct
*/
private $model;
/**
- * @var PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Pricing\PriceInfoInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $priceInfoMock;
@@ -49,9 +43,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')
->getMockForAbstractClass();
@@ -59,7 +50,7 @@ protected function setUp()
$this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')
->getMockForAbstractClass();
- $this->model = new ConfigurableProduct(
+ $this->model = new \Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct(
$this->saleableItem,
null,
$this->calculator,
@@ -82,7 +73,7 @@ public function testGetValue()
->getMock();
$this->priceInfoMock->expects($this->once())
->method('getPrice')
- ->with(ConfigurableProduct::PRICE_CODE)
+ ->with(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
->willReturn($priceMock);
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
@@ -109,11 +100,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(\Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct::PRICE_CODE)
+ ->willReturn($priceMock);
+
+ $this->assertEquals(100, $this->model->getValue());
}
}
diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductPriceIsNotZero.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductPriceIsNotZero.php
new file mode 100644
index 0000000000000..24f6222dac09e
--- /dev/null
+++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AssertProductPriceIsNotZero.php
@@ -0,0 +1,47 @@
+getLinksBlock()->openLink('My Account');
+ $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Wish List');
+ $wishlistItem = $wishlistIndex->getWishlistBlock()->getProductItemsBlock()->getItemProduct($product);
+
+ \PHPUnit_Framework_Assert::assertNotEquals(
+ '0.00',
+ $wishlistItem->getPrice(),
+ $product->getName() . ' has zero price on Wish List page.'
+ );
+ }
+
+ /**
+ * Returns a string representation of the object.
+ *
+ * @return string
+ */
+ public function toString()
+ {
+ return 'Product price is not zero in default Wish List.';
+ }
+}
diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php
index 40039229a4389..2eb0812299115 100644
--- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php
+++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.php
@@ -49,15 +49,16 @@ public function __prepare(Customer $customer)
*
* @param Customer $customer
* @param string $product
+ * @param bool $configure
* @return array
*/
- public function test(Customer $customer, $product)
+ public function test(Customer $customer, $product, $configure = true)
{
$product = $this->createProducts($product)[0];
// Steps:
$this->loginCustomer($customer);
- $this->addToWishlist([$product], true);
+ $this->addToWishlist([$product], $configure);
return ['product' => $product];
}
diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml
index 07d7c7f4e5b38..e2382c43e0bee 100644
--- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/AddProductToWishlistEntityTest.xml
@@ -50,5 +50,12 @@
+
+ configurableProduct::default
+ false
+
+
+
+