Skip to content

Commit 6bf2c49

Browse files
author
Sergey Semenov
committed
MAGETWO-52067: Downloadable product price doesn't include link price in wishlist
1 parent 20cd697 commit 6bf2c49

File tree

8 files changed

+138
-24
lines changed

8 files changed

+138
-24
lines changed

app/code/Magento/Bundle/Test/Unit/Pricing/Price/BundleSelectionPriceTest.php

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,8 @@ protected function setUp()
9191
'',
9292
false
9393
);
94-
$this->calculatorMock = $this->getMock(
95-
'Magento\Framework\Pricing\Adjustment\CalculatorInterface',
96-
[],
97-
[],
98-
'',
99-
false,
100-
true,
101-
false
102-
);
94+
$this->calculatorMock = $this->getMockBuilder('Magento\Framework\Pricing\Adjustment\CalculatorInterface')
95+
->getMockForAbstractClass();
10396
$this->eventManagerMock = $this->getMock(
10497
'Magento\Framework\Event\Manager',
10598
['dispatch'],
@@ -349,4 +342,42 @@ public function testGetProductDynamicBundle()
349342
$product = $this->selectionPrice->getProduct();
350343
$this->assertEquals($this->productMock, $product);
351344
}
345+
346+
public function testGetAmount()
347+
{
348+
$this->setupSelectionPrice();
349+
350+
$price = 10.;
351+
$amount = 20.;
352+
353+
$this->priceInfoMock->expects($this->once())
354+
->method('getPrice')
355+
->with(\Magento\Bundle\Pricing\Price\FinalPrice::PRICE_CODE)
356+
->willReturn($this->finalPriceMock);
357+
358+
$this->finalPriceMock->expects($this->once())
359+
->method('getValue')
360+
->willReturn($price);
361+
362+
$this->discountCalculatorMock->expects($this->once())
363+
->method('calculateDiscount')
364+
->with($this->bundleMock, $price)
365+
->willReturn($price);
366+
367+
$this->priceCurrencyMock->expects($this->once())
368+
->method('round')
369+
->with($price)
370+
->willReturn($price);
371+
372+
$this->bundleMock->expects($this->any())
373+
->method('getPriceType')
374+
->willReturn(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC);
375+
376+
$this->calculatorMock->expects($this->once())
377+
->method('getAmount')
378+
->with($price, $this->productMock, null)
379+
->willReturn($amount);
380+
381+
$this->assertEquals($amount, $this->selectionPrice->getAmount());
382+
}
352383
}

app/code/Magento/Catalog/Test/Unit/Pricing/Price/BasePriceTest.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class BasePriceTest extends \PHPUnit_Framework_TestCase
2929
protected $saleableItemMock;
3030

3131
/**
32-
* @var \Magento\Framework\Pricing\Adjustment\Calculator
32+
* @var \Magento\Framework\Pricing\Adjustment\Calculator|\PHPUnit_Framework_MockObject_MockObject
3333
*/
3434
protected $calculatorMock;
3535

@@ -111,4 +111,23 @@ public function getValueDataProvider()
111111
{
112112
return [[77, 77], [0, 0], [false, 99]];
113113
}
114+
115+
public function testGetAmount()
116+
{
117+
$amount = 20.;
118+
119+
$priceMock = $this->getMockBuilder('Magento\Framework\Pricing\Price\PriceInterface')
120+
->getMockForAbstractClass();
121+
122+
$this->priceInfoMock->expects($this->once())
123+
->method('getPrices')
124+
->willReturn([$priceMock]);
125+
126+
$this->calculatorMock->expects($this->once())
127+
->method('getAmount')
128+
->with(false, $this->saleableItemMock)
129+
->willReturn($amount);
130+
131+
$this->assertEquals($amount, $this->basePrice->getAmount());
132+
}
114133
}

app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProductPrice.php renamed to app/code/Magento/Wishlist/Pricing/ConfiguredPrice/ConfigurableProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Catalog\Pricing\Price\ConfiguredPriceInterface;
1010
use Magento\Catalog\Pricing\Price\FinalPrice;
1111

12-
class ConfigurableProductPrice extends FinalPrice implements ConfiguredPriceInterface
12+
class ConfigurableProduct extends FinalPrice implements ConfiguredPriceInterface
1313
{
1414
/**
1515
* @var ItemInterface

app/code/Magento/Wishlist/Pricing/ConfiguredPrice/DownloadablePrice.php renamed to app/code/Magento/Wishlist/Pricing/ConfiguredPrice/Downloadable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Magento\Catalog\Pricing\Price\ConfiguredPriceInterface;
1010
use Magento\Catalog\Pricing\Price\FinalPrice;
1111

12-
class DownloadablePrice extends FinalPrice implements ConfiguredPriceInterface
12+
class Downloadable extends FinalPrice implements ConfiguredPriceInterface
1313
{
1414
/**
1515
* Price type configured

app/code/Magento/Wishlist/Test/Unit/Model/Rss/WishlistTest.php

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class WishlistTest extends \PHPUnit_Framework_TestCase
5353
protected $catalogOutputMock;
5454

5555
/**
56-
* @var \Magento\Catalog\Helper\Output
56+
* @var \Magento\Catalog\Helper\Output|\PHPUnit_Framework_MockObject_MockObject
5757
*/
5858
protected $layoutMock;
5959

@@ -315,4 +315,68 @@ public function testIsAuthRequired()
315315
->will($this->returnValue($wishlist));
316316
$this->assertEquals(false, $this->model->isAuthRequired());
317317
}
318+
319+
public function testGetProductPriceHtmlBlockDoesntExists()
320+
{
321+
$price = 10.;
322+
323+
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
324+
->disableOriginalConstructor()
325+
->getMock();
326+
327+
$renderBlockMock = $this->getMockBuilder('Magento\Framework\Pricing\Render')
328+
->disableOriginalConstructor()
329+
->getMock();
330+
$renderBlockMock->expects($this->once())
331+
->method('render')
332+
->with(
333+
'wishlist_configured_price',
334+
$productMock,
335+
['zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST]
336+
)
337+
->willReturn($price);
338+
339+
$this->layoutMock->expects($this->once())
340+
->method('getBlock')
341+
->with('product.price.render.default')
342+
->willReturn(false);
343+
$this->layoutMock->expects($this->once())
344+
->method('createBlock')
345+
->with(
346+
'Magento\Framework\Pricing\Render',
347+
'product.price.render.default',
348+
['data' => ['price_render_handle' => 'catalog_product_prices']]
349+
)
350+
->willReturn($renderBlockMock);
351+
352+
$this->assertEquals($price, $this->model->getProductPriceHtml($productMock));
353+
}
354+
355+
public function testGetProductPriceHtmlBlockExists()
356+
{
357+
$price = 10.;
358+
359+
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')
360+
->disableOriginalConstructor()
361+
->getMock();
362+
363+
$renderBlockMock = $this->getMockBuilder('Magento\Framework\Pricing\Render')
364+
->disableOriginalConstructor()
365+
->getMock();
366+
$renderBlockMock->expects($this->once())
367+
->method('render')
368+
->with(
369+
'wishlist_configured_price',
370+
$productMock,
371+
['zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST]
372+
)
373+
->willReturn($price);
374+
375+
$this->layoutMock->expects($this->once())
376+
->method('getBlock')
377+
->with('product.price.render.default')
378+
->willReturn($renderBlockMock);
379+
380+
$this->assertEquals($price, $this->model->getProductPriceHtml($productMock));
381+
}
318382
}

app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductPriceTest.php renamed to app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/ConfigurableProductTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
use Magento\Framework\Pricing\PriceCurrencyInterface;
1010
use Magento\Framework\Pricing\PriceInfoInterface;
1111
use Magento\Framework\Pricing\SaleableInterface;
12-
use Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProductPrice;
12+
use Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct;
1313

14-
class ConfigurableProductPriceTest extends \PHPUnit_Framework_TestCase
14+
class ConfigurableProductTest extends \PHPUnit_Framework_TestCase
1515
{
1616
/**
1717
* @var SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -29,7 +29,7 @@ class ConfigurableProductPriceTest extends \PHPUnit_Framework_TestCase
2929
private $priceCurrency;
3030

3131
/**
32-
* @var ConfigurableProductPrice
32+
* @var ConfigurableProduct
3333
*/
3434
private $model;
3535

@@ -59,7 +59,7 @@ protected function setUp()
5959
$this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')
6060
->getMockForAbstractClass();
6161

62-
$this->model = new ConfigurableProductPrice(
62+
$this->model = new ConfigurableProduct(
6363
$this->saleableItem,
6464
null,
6565
$this->calculator,
@@ -82,7 +82,7 @@ public function testGetValue()
8282
->getMock();
8383
$this->priceInfoMock->expects($this->once())
8484
->method('getPrice')
85-
->with(ConfigurableProductPrice::PRICE_CODE)
85+
->with(ConfigurableProduct::PRICE_CODE)
8686
->willReturn($priceMock);
8787

8888
$productMock = $this->getMockBuilder('Magento\Catalog\Model\Product')

app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/DownloadablePriceTest.php renamed to app/code/Magento/Wishlist/Test/Unit/Pricing/ConfiguredPrice/DownloadableTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use Magento\Framework\Pricing\PriceCurrencyInterface;
1111
use Magento\Framework\Pricing\PriceInfoInterface;
1212
use Magento\Framework\Pricing\SaleableInterface;
13-
use Magento\Wishlist\Pricing\ConfiguredPrice\DownloadablePrice;
13+
use Magento\Wishlist\Pricing\ConfiguredPrice\Downloadable;
1414

15-
class DownloadablePriceTest extends \PHPUnit_Framework_TestCase
15+
class DownloadableTest extends \PHPUnit_Framework_TestCase
1616
{
1717
/**
1818
* @var SaleableInterface|\PHPUnit_Framework_MockObject_MockObject
@@ -30,7 +30,7 @@ class DownloadablePriceTest extends \PHPUnit_Framework_TestCase
3030
private $priceCurrency;
3131

3232
/**
33-
* @var DownloadablePrice
33+
* @var Downloadable
3434
*/
3535
private $model;
3636

@@ -62,7 +62,7 @@ protected function setUp()
6262
$this->priceCurrency = $this->getMockBuilder('Magento\Framework\Pricing\PriceCurrencyInterface')
6363
->getMockForAbstractClass();
6464

65-
$this->model = new DownloadablePrice(
65+
$this->model = new Downloadable(
6666
$this->saleableItem,
6767
null,
6868
$this->calculator,

app/code/Magento/Wishlist/etc/di.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@
5050
<virtualType name="Magento\ConfigurableProduct\Pricing\Price\Pool" type="Magento\Framework\Pricing\Price\Pool">
5151
<arguments>
5252
<argument name="prices" xsi:type="array">
53-
<item name="wishlist_configured_price" xsi:type="string">Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProductPrice</item>
53+
<item name="wishlist_configured_price" xsi:type="string">Magento\Wishlist\Pricing\ConfiguredPrice\ConfigurableProduct</item>
5454
</argument>
5555
</arguments>
5656
</virtualType>
5757
<virtualType name="Magento\Downloadable\Pricing\Price\Pool" type="Magento\Framework\Pricing\Price\Pool">
5858
<arguments>
5959
<argument name="prices" xsi:type="array">
60-
<item name="wishlist_configured_price" xsi:type="string">Magento\Wishlist\Pricing\ConfiguredPrice\DownloadablePrice</item>
60+
<item name="wishlist_configured_price" xsi:type="string">Magento\Wishlist\Pricing\ConfiguredPrice\Downloadable</item>
6161
</argument>
6262
</arguments>
6363
</virtualType>

0 commit comments

Comments
 (0)