Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into BUGS
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/code/Magento/Catalog/etc/di.xml
  • Loading branch information
slavvka committed Dec 7, 2016
2 parents d3922c1 + ea0272d commit 1cacbac
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 41 deletions.
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();
}
}
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);
}
33 changes: 32 additions & 1 deletion app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
use Magento\Framework\Pricing\Render;
use Magento\Framework\Pricing\Render\PriceBox as BasePriceBox;
use Magento\Msrp\Pricing\Price\MsrpPrice;
use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\Pricing\SaleableInterface;
use Magento\Framework\Pricing\Price\PriceInterface;
use Magento\Framework\Pricing\Render\RendererPool;

/**
* Class for final_price rendering
Expand All @@ -19,12 +24,38 @@
*/
class FinalPriceBox extends BasePriceBox
{
/**
* @var SalableResolverInterface
*/
private $salableResolver;

/**
* @param Context $context
* @param SaleableInterface $saleableItem
* @param PriceInterface $price
* @param RendererPool $rendererPool
* @param array $data
* @param SalableResolverInterface $salableResolver
*/
public function __construct(
Context $context,
SaleableInterface $saleableItem,
PriceInterface $price,
RendererPool $rendererPool,
array $data = [],
SalableResolverInterface $salableResolver = null
) {
parent::__construct($context, $saleableItem, $price, $rendererPool, $data);
$this->salableResolver = $salableResolver ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(SalableResolverInterface::class);
}

/**
* @return string
*/
protected function _toHtml()
{
if (!$this->getSaleableItem() || $this->getSaleableItem()->getCanShowPrice() === false) {
if (!$this->salableResolver->isSalable($this->getSaleableItem())) {
return '';
}

Expand Down
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Magento\Catalog\Test\Unit\Pricing\Render;

use Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface;

/**
* Class FinalPriceBoxTest
*
Expand Down Expand Up @@ -58,11 +60,16 @@ class FinalPriceBoxTest extends \PHPUnit_Framework_TestCase
*/
protected $price;

/**
* @var SalableResolverInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $salableResolverMock;

protected function setUp()
{
$this->product = $this->getMock(
\Magento\Catalog\Model\Product::class,
['getPriceInfo', '__wakeup', 'getCanShowPrice'],
['getPriceInfo', '__wakeup', 'getCanShowPrice', 'isSalable'],
[],
'',
false
Expand All @@ -78,9 +85,7 @@ protected function setUp()
$this->priceBox = $this->getMock(\Magento\Framework\Pricing\Render\PriceBox::class, [], [], '', false);
$this->logger = $this->getMock(\Psr\Log\LoggerInterface::class);

$this->layout->expects($this->any())
->method('getBlock')
->will($this->returnValue($this->priceBox));
$this->layout->expects($this->any())->method('getBlock')->willReturn($this->priceBox);

$cacheState = $this->getMockBuilder(\Magento\Framework\App\Cache\StateInterface::class)
->getMockForAbstractClass();
Expand All @@ -93,12 +98,9 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();

$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
->getMockForAbstractClass();

$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
->getMockForAbstractClass();
$urlBuilder = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)->getMockForAbstractClass();

$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)->getMockForAbstractClass();
$storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
->setMethods(['getStore', 'getCode'])
->getMockForAbstractClass();
Expand Down Expand Up @@ -144,14 +146,19 @@ protected function setUp()
->will($this->returnValue(\Magento\Catalog\Pricing\Price\FinalPrice::PRICE_CODE));

$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->salableResolverMock = $this->getMockBuilder(SalableResolverInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass();

$this->object = $objectManager->getObject(
\Magento\Catalog\Pricing\Render\FinalPriceBox::class,
[
'context' => $context,
'saleableItem' => $this->product,
'rendererPool' => $this->rendererPool,
'price' => $this->price,
'data' => ['zone' => 'test_zone', 'list_category_page' => true]
'data' => ['zone' => 'test_zone', 'list_category_page' => true],
'salableResolver' => $this->salableResolverMock
]
);
}
Expand All @@ -169,6 +176,8 @@ public function testRenderMsrpDisabled()
->with($this->equalTo($this->product))
->will($this->returnValue(false));

$this->salableResolverMock->expects($this->once())->method('isSalable')->with($this->product)->willReturn(true);

$result = $this->object->toHtml();

//assert price wrapper
Expand All @@ -177,6 +186,18 @@ public function testRenderMsrpDisabled()
$this->assertRegExp('/[final_price]/', $result);
}

public function testNotSalableItem()
{
$this->salableResolverMock
->expects($this->once())
->method('isSalable')
->with($this->product)
->willReturn(false);
$result = $this->object->toHtml();

$this->assertEmpty($result);
}

public function testRenderMsrpEnabled()
{
$priceType = $this->getMock(\Magento\Msrp\Pricing\Price\MsrpPrice::class, [], [], '', false);
Expand Down Expand Up @@ -211,6 +232,8 @@ public function testRenderMsrpEnabled()
->with('msrp_price', $this->product, $arguments)
->will($this->returnValue($priceBoxRender));

$this->salableResolverMock->expects($this->once())->method('isSalable')->with($this->product)->willReturn(true);

$result = $this->object->toHtml();

//assert price wrapper
Expand All @@ -230,6 +253,8 @@ public function testRenderMsrpNotRegisteredException()
->with($this->equalTo('msrp_price'))
->will($this->throwException(new \InvalidArgumentException()));

$this->salableResolverMock->expects($this->once())->method('isSalable')->with($this->product)->willReturn(true);

$result = $this->object->toHtml();

//assert price wrapper
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<preference for="Magento\Catalog\Api\Data\CategorySearchResultsInterface" type="Magento\Framework\Api\SearchResults" />
<preference for="Magento\Catalog\Model\Config\Source\ProductPriceOptionsInterface" type="Magento\Catalog\Model\Config\Source\Product\Options\Price"/>
<preference for="Magento\Catalog\Model\Indexer\Product\Flat\Table\BuilderInterface" type="Magento\Catalog\Model\Indexer\Product\Flat\Table\Builder"/>
<preference for="Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolverInterface" type="Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver"/>
<preference for="Magento\Catalog\Model\Product\Media\ConfigInterface" type="Magento\Catalog\Model\Product\Media\Config"/>
<preference for="Magento\Framework\View\Asset\ContextInterface" type="Magento\Catalog\Model\View\Asset\Image\Context"/>
<type name="Magento\Customer\Model\ResourceModel\Visitor">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ public function resolvePrice(\Magento\Framework\Pricing\SaleableInterface $produ
$productPrice = $this->priceResolver->resolvePrice($subProduct);
$price = $price ? min($price, $productPrice) : $productPrice;
}
if ($price === null) {
throw new \Magento\Framework\Exception\LocalizedException(
__('Configurable product "%1" does not have sub-products', $product->getSku())
);
}

return (float)$price;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,6 @@ protected function setUp()
);
}

/**
* situation: There are no used products, thus there are no prices
*
* @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testResolvePriceWithNoPrices()
{
$product = $this->getMockBuilder(
\Magento\Catalog\Model\Product::class
)->disableOriginalConstructor()->getMock();

$product->expects($this->once())->method('getSku')->willReturn('Kiwi');

$this->lowestPriceOptionsProvider->expects($this->once())->method('getProducts')->willReturn([]);

$this->resolver->resolvePrice($product);
}

/**
* situation: one product is supplying the price, which could be a price of zero (0)
*
Expand Down
13 changes: 9 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,20 +217,25 @@
"tinymce/tinymce": "lib/web/tiny_mce"
}
},
"config": {
"use-include-path": true
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/"
},
"psr-0": {
"": "app/code/"
"": [
"app/code/",
"var/generation"
]
},
"files": [
"app/etc/NonComposerComponentRegistration.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
]
},
"autoload-dev": {
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<constraint name="Magento\Sales\Test\Constraint\AssertOrderGrandTotal"/>
</variation>
<variation name="OnePageCheckoutTestVariation5" summary="Guest Checkout using Check/Money Order and Free Shipping with Prices/Taxes Verifications" ticketId="MAGETWO-12412">
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test</data>
<data name="tag" xsi:type="string">test_type:acceptance_test, test_type:extended_acceptance_test, stable:no</data>
<data name="products/0" xsi:type="string">catalogProductSimple::product_10_dollar</data>
<data name="products/1" xsi:type="string">configurableProduct::with_one_option</data>
<data name="products/2" xsi:type="string">bundleProduct::bundle_fixed_100_dollar_product</data>
Expand Down
4 changes: 4 additions & 0 deletions lib/web/css/source/components/_modals.less
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,17 @@
// If applied, switching outer popup scroll to inner
&._inner-scroll {
overflow-y: visible;

.ie11 &,
.ie10 &,
.ie9 & {
overflow-y: auto;
}

.modal-inner-wrap {
max-height: 90%;

.ie11 &,
.ie10 &,
.ie9 & {
max-height: none;
Expand Down
Loading

0 comments on commit 1cacbac

Please sign in to comment.