-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-51181: [GITHUB] Configurable product's last attribute with pr…
…ice zero results in error #3912 - commit
- Loading branch information
Mike Weis
committed
Mar 31, 2016
1 parent
ce68a6d
commit 59f9546
Showing
6 changed files
with
118 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...ode/Magento/ConfigurableProduct/Test/Unit/Pricing/Price/ConfigurablePriceResolverTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\ConfigurableProduct\Test\Unit\Pricing\Price; | ||
|
||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
|
||
class ConfigurablePriceResolverTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\ConfigurableProduct\Pricing\Price\ConfigurablePriceResolver | ||
*/ | ||
protected $resolver; | ||
|
||
/** | ||
* @var PHPUnit_Framework_MockObject_MockObject | \Magento\ConfigurableProduct\Model\Product\Type\Configurable | ||
*/ | ||
protected $configurable; | ||
|
||
/** | ||
* @var PHPUnit_Framework_MockObject_MockObject | \Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface | ||
*/ | ||
protected $priceResolver; | ||
|
||
protected function setUp() | ||
{ | ||
$className = 'Magento\ConfigurableProduct\Model\Product\Type\Configurable'; | ||
$this->configurable = $this->getMock($className, ['getUsedProducts'], [], '', false); | ||
|
||
$className = 'Magento\ConfigurableProduct\Pricing\Price\PriceResolverInterface'; | ||
$this->priceResolver = $this->getMockForAbstractClass($className, [], '', false, true, true, ['resolvePrice']); | ||
|
||
$objectManager = new ObjectManager($this); | ||
$this->resolver = $objectManager->getObject( | ||
'Magento\ConfigurableProduct\Pricing\Price\ConfigurablePriceResolver', | ||
[ | ||
'priceResolver' => $this->priceResolver, | ||
'configurable' => $this->configurable, | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* situation: There are no used products, thus there are no prices | ||
* | ||
* @expectedException \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function testResolvePriceWithNoPrices() | ||
{ | ||
$product = $this->getMockForAbstractClass( | ||
'Magento\Framework\Pricing\SaleableInterface', | ||
[], | ||
'', | ||
false, | ||
true, | ||
true, | ||
['getName'] | ||
); | ||
$product->expects($this->once())->method('getName')->willReturn('Kiwi'); | ||
|
||
$this->configurable->expects($this->once())->method('getUsedProducts')->willReturn([]); | ||
|
||
$this->resolver->resolvePrice($product); | ||
} | ||
|
||
/** | ||
* situation: one product is supplying the price, which could be a price of zero (0) | ||
* | ||
* @dataProvider testResolvePriceDataProvider | ||
*/ | ||
public function testResolvePrice($expectedValue) | ||
{ | ||
$price = $expectedValue; | ||
|
||
$product = $this->getMockForAbstractClass( | ||
'Magento\Framework\Pricing\SaleableInterface', | ||
[], | ||
'', | ||
false, | ||
true, | ||
true, | ||
['getName'] | ||
); | ||
$product->expects($this->never())->method('getName'); | ||
|
||
$this->configurable->expects($this->once())->method('getUsedProducts')->willReturn([$product]); | ||
$this->priceResolver->expects($this->atLeastOnce())->method('resolvePrice')->willReturn($price); | ||
|
||
$this->assertEquals($expectedValue, $this->resolver->resolvePrice($product)); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function testResolvePriceDataProvider() | ||
{ | ||
return [ | ||
'price of zero' => [0.00], | ||
'price of five' => [5], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters