-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'mainline/develop' into BUGS
# Conflicts: # app/code/Magento/Catalog/etc/di.xml
- Loading branch information
Showing
13 changed files
with
190 additions
and
41 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
app/code/Magento/Catalog/Model/Product/Pricing/Renderer/SalableResolver.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,24 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Model\Product\Pricing\Renderer; | ||
|
||
/** | ||
* Resolvers check whether product available for sale or not | ||
*/ | ||
class SalableResolver implements SalableResolverInterface | ||
{ | ||
/** | ||
* Check whether product available for sale | ||
* | ||
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem | ||
* @return boolean | ||
*/ | ||
public function isSalable(\Magento\Framework\Pricing\SaleableInterface $salableItem) | ||
{ | ||
return $salableItem->getCanShowPrice() !== false && $salableItem->isSalable(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/code/Magento/Catalog/Model/Product/Pricing/Renderer/SalableResolverInterface.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,21 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Model\Product\Pricing\Renderer; | ||
|
||
/** | ||
* Interface resolver checks whether product available for sale | ||
*/ | ||
interface SalableResolverInterface | ||
{ | ||
/** | ||
* Check whether product available for sale | ||
* | ||
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem | ||
* @return boolean | ||
*/ | ||
public function isSalable(\Magento\Framework\Pricing\SaleableInterface $salableItem); | ||
} |
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
60 changes: 60 additions & 0 deletions
60
app/code/Magento/Catalog/Test/Unit/Model/Product/Pricing/Renderer/SalableResolverTest.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,60 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Catalog\Test\Unit\Model\Product\Pricing\Renderer; | ||
|
||
class SalableResolverTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver | ||
*/ | ||
protected $object; | ||
|
||
/** | ||
* @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
protected $product; | ||
|
||
protected function setUp() | ||
{ | ||
$this->product = $this->getMock( | ||
\Magento\Catalog\Model\Product::class, | ||
['__wakeup', 'getCanShowPrice', 'isSalable'], | ||
[], | ||
'', | ||
false | ||
); | ||
|
||
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->object = $objectManager->getObject( | ||
\Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver::class | ||
); | ||
} | ||
|
||
public function testSalableItem() | ||
{ | ||
$this->product->expects($this->any()) | ||
->method('getCanShowPrice') | ||
->willReturn(true); | ||
|
||
$this->product->expects($this->any())->method('isSalable')->willReturn(true); | ||
|
||
$result = $this->object->isSalable($this->product); | ||
$this->assertTrue($result); | ||
} | ||
|
||
public function testNotSalableItem() | ||
{ | ||
$this->product->expects($this->any()) | ||
->method('getCanShowPrice') | ||
->willReturn(true); | ||
|
||
$this->product->expects($this->any())->method('isSalable')->willReturn(false); | ||
|
||
$result = $this->object->isSalable($this->product); | ||
$this->assertFalse($result); | ||
} | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.