Skip to content

Commit dc703f4

Browse files
committed
MAGETWO-8709: [GITHUB] Child product image should be shown in Wishist if options are selected for configurable product #8168
- fixing formatting
1 parent 838182a commit dc703f4

File tree

7 files changed

+34
-137
lines changed

7 files changed

+34
-137
lines changed

app/code/Magento/ConfigurableProduct/Block/Cart/Item/Renderer/Configurable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Configurable extends Renderer implements IdentityInterface
1919
{
2020
/**
2121
* Path in config to the setting which defines if parent or child product should be used to generate a thumbnail.
22+
* @deprecated moved to model because of class refactoring
23+
* @see \Magento\ConfigurableProduct\Model\Product\Configuration\Item\ItemProductResolver::CONFIG_THUMBNAIL_SOURCE
2224
*/
2325
const CONFIG_THUMBNAIL_SOURCE = 'checkout/cart/configurable_product_image';
2426

@@ -57,7 +59,7 @@ public function getOptionList()
5759

5860
/**
5961
* {@inheritdoc}
60-
* @deprecated because parent can handle the logic for images of all product types
62+
* @deprecated because now parent handles the logic for images of all product types
6163
* @see \Magento\Checkout\Block\Cart\Item\Renderer::getProductForThumbnail
6264
*/
6365
public function getProductForThumbnail()

app/code/Magento/ConfigurableProduct/Model/Product/Configuration/Item/ItemProductResolver.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
*/
1818
class ItemProductResolver implements ItemResolverInterface
1919
{
20+
/**
21+
* Path in config to the setting which defines if parent or child product should be used to generate a thumbnail.
22+
*/
2023
const CONFIG_THUMBNAIL_SOURCE = 'checkout/cart/configurable_product_image';
2124

2225
/**
@@ -43,7 +46,7 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
4346
*/
4447
$parentItem = $item->getProduct();
4548
$config = $this->scopeConfig->getValue(
46-
\Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::CONFIG_THUMBNAIL_SOURCE,
49+
self::CONFIG_THUMBNAIL_SOURCE,
4750
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
4851
);
4952

app/code/Magento/ConfigurableProduct/Test/Unit/Block/Cart/Item/Renderer/ConfigurableTest.php

Lines changed: 16 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -11,102 +11,48 @@
1111
class ConfigurableTest extends \PHPUnit\Framework\TestCase
1212
{
1313
/** @var \Magento\Framework\View\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
14-
protected $_configManager;
14+
private $configManager;
1515

1616
/** @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject */
17-
protected $_imageHelper;
17+
private $imageHelper;
1818

1919
/** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
20-
protected $_scopeConfig;
20+
private $scopeConfig;
2121

2222
/** @var \PHPUnit_Framework_MockObject_MockObject */
23-
protected $productConfigMock;
23+
private $productConfigMock;
2424

2525
/** @var Renderer */
26-
protected $_renderer;
26+
private $renderer;
2727

2828
protected function setUp()
2929
{
3030
parent::setUp();
3131
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
32-
$this->_configManager = $this->createMock(\Magento\Framework\View\ConfigInterface::class);
33-
$this->_imageHelper = $this->createPartialMock(
32+
$this->configManager = $this->createMock(\Magento\Framework\View\ConfigInterface::class);
33+
$this->imageHelper = $this->createPartialMock(
3434
\Magento\Catalog\Helper\Image::class,
3535
['init', 'resize', '__toString']
3636
);
37-
$this->_scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
37+
$this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
3838
$this->productConfigMock = $this->createMock(\Magento\Catalog\Helper\Product\Configuration::class);
39-
$this->_renderer = $objectManagerHelper->getObject(
39+
$this->renderer = $objectManagerHelper->getObject(
4040
\Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::class,
4141
[
42-
'viewConfig' => $this->_configManager,
43-
'imageHelper' => $this->_imageHelper,
44-
'scopeConfig' => $this->_scopeConfig,
42+
'viewConfig' => $this->configManager,
43+
'imageHelper' => $this->imageHelper,
44+
'scopeConfig' => $this->scopeConfig,
4545
'productConfig' => $this->productConfigMock
4646
]
4747
);
4848
}
4949

50-
/**
51-
* Initialize parent configurable product and child product.
52-
*
53-
* @param bool $childHasThumbnail
54-
* @param bool $useParentThumbnail
55-
* @return \Magento\Catalog\Model\Product[]|\PHPUnit_Framework_MockObject_MockObject[]
56-
*/
57-
protected function _initProducts($childHasThumbnail = true, $useParentThumbnail = false)
58-
{
59-
/** Set option which can force usage of parent product thumbnail when configurable product is displayed */
60-
$thumbnailToBeUsed = $useParentThumbnail
61-
? ThumbnailSource::OPTION_USE_PARENT_IMAGE
62-
: ThumbnailSource::OPTION_USE_OWN_IMAGE;
63-
$this->_scopeConfig->expects(
64-
$this->any()
65-
)->method(
66-
'getValue'
67-
)->with(
68-
Renderer::CONFIG_THUMBNAIL_SOURCE
69-
)->will(
70-
$this->returnValue($thumbnailToBeUsed)
71-
);
72-
73-
/** Initialized parent product */
74-
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $parentProduct */
75-
$parentProduct = $this->createMock(\Magento\Catalog\Model\Product::class);
76-
77-
/** Initialize child product */
78-
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $childProduct */
79-
$childProduct = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getThumbnail', '__wakeup']);
80-
$childThumbnail = $childHasThumbnail ? 'thumbnail.jpg' : 'no_selection';
81-
$childProduct->expects($this->any())->method('getThumbnail')->will($this->returnValue($childThumbnail));
82-
83-
/** Mock methods which return parent and child products */
84-
/** @var \Magento\Quote\Model\Quote\Item\Option|\PHPUnit_Framework_MockObject_MockObject $itemOption */
85-
$itemOption = $this->createMock(\Magento\Quote\Model\Quote\Item\Option::class);
86-
$itemOption->expects($this->any())->method('getProduct')->will($this->returnValue($childProduct));
87-
/** @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $item */
88-
$item = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
89-
$item->expects($this->any())->method('getProduct')->will($this->returnValue($parentProduct));
90-
$item->expects(
91-
$this->any()
92-
)->method(
93-
'getOptionByCode'
94-
)->with(
95-
'simple_product'
96-
)->will(
97-
$this->returnValue($itemOption)
98-
);
99-
$this->_renderer->setItem($item);
100-
101-
return ['parentProduct' => $parentProduct, 'childProduct' => $childProduct];
102-
}
103-
10450
public function testGetOptionList()
10551
{
10652
$itemMock = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
107-
$this->_renderer->setItem($itemMock);
53+
$this->renderer->setItem($itemMock);
10854
$this->productConfigMock->expects($this->once())->method('getOptions')->with($itemMock);
109-
$this->_renderer->getOptionList();
55+
$this->renderer->getOptionList();
11056
}
11157

11258
public function testGetIdentities()
@@ -116,7 +62,7 @@ public function testGetIdentities()
11662
$product->expects($this->exactly(2))->method('getIdentities')->will($this->returnValue($productTags));
11763
$item = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
11864
$item->expects($this->exactly(2))->method('getProduct')->will($this->returnValue($product));
119-
$this->_renderer->setItem($item);
120-
$this->assertEquals(array_merge($productTags, $productTags), $this->_renderer->getIdentities());
65+
$this->renderer->setItem($item);
66+
$this->assertEquals(array_merge($productTags, $productTags), $this->renderer->getIdentities());
12167
}
12268
}

app/code/Magento/GroupedProduct/Block/Cart/Item/Renderer/Grouped.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Grouped extends Renderer implements IdentityInterface
1919
{
2020
/**
2121
* Path in config to the setting which defines if parent or child product should be used to generate a thumbnail.
22+
* @deprecated moved to model because of class refactoring
23+
* @see \Magento\GroupedProduct\Model\Product\Configuration\Item\ItemProductResolver::CONFIG_THUMBNAIL_SOURCE
2224
*/
2325
const CONFIG_THUMBNAIL_SOURCE = 'checkout/cart/grouped_product_image';
2426

@@ -38,7 +40,7 @@ public function getGroupedProduct()
3840

3941
/**
4042
* {@inheritdoc}
41-
* @deprecated because parent can handle the logic for images of all product types
43+
* @deprecated because now parent handles the logic for images of all product types
4244
* @see \Magento\Checkout\Block\Cart\Item\Renderer::getProductForThumbnail
4345
*/
4446
public function getProductForThumbnail()

app/code/Magento/GroupedProduct/Model/Product/Configuration/Item/ItemProductResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
4545
* or if child product thumbnail is not available
4646
*/
4747
$config = $this->scopeConfig->getValue(
48-
\Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE,
48+
self::CONFIG_THUMBNAIL_SOURCE,
4949
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
5050
);
5151
$childProduct = $item->getProduct();

app/code/Magento/GroupedProduct/Test/Unit/Block/Cart/Item/Renderer/GroupedTest.php

Lines changed: 7 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -11,84 +11,30 @@
1111
class GroupedTest extends \PHPUnit\Framework\TestCase
1212
{
1313
/** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
14-
protected $_scopeConfig;
14+
private $scopeConfig;
1515

1616
/** @var Renderer */
17-
protected $_renderer;
17+
private $renderer;
1818

1919
protected function setUp()
2020
{
2121
parent::setUp();
2222
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
23-
$this->_scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
24-
$this->_renderer = $objectManagerHelper->getObject(
23+
$this->scopeConfig = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
24+
$this->renderer = $objectManagerHelper->getObject(
2525
\Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::class,
26-
['scopeConfig' => $this->_scopeConfig]
26+
['scopeConfig' => $this->scopeConfig]
2727
);
2828
}
2929

30-
/**
31-
* Initialize parent grouped product and child product.
32-
*
33-
* @param bool $childHasThumbnail
34-
* @param bool $useParentThumbnail
35-
* @return \Magento\Catalog\Model\Product[]|\PHPUnit_Framework_MockObject_MockObject[]
36-
*/
37-
protected function _initProducts($childHasThumbnail = true, $useParentThumbnail = false)
38-
{
39-
/** Set option which can force usage of parent product thumbnail when grouped product is displayed */
40-
$thumbnailToBeUsed = $useParentThumbnail
41-
? ThumbnailSource::OPTION_USE_PARENT_IMAGE
42-
: ThumbnailSource::OPTION_USE_OWN_IMAGE;
43-
$this->_scopeConfig->expects(
44-
$this->any()
45-
)->method(
46-
'getValue'
47-
)->with(
48-
Renderer::CONFIG_THUMBNAIL_SOURCE
49-
)->will(
50-
$this->returnValue($thumbnailToBeUsed)
51-
);
52-
53-
/** Initialized parent product */
54-
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $parentProduct */
55-
$parentProduct = $this->createMock(\Magento\Catalog\Model\Product::class);
56-
57-
/** Initialize child product */
58-
/** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $childProduct */
59-
$childProduct = $this->createPartialMock(\Magento\Catalog\Model\Product::class, ['getThumbnail', '__wakeup']);
60-
$childThumbnail = $childHasThumbnail ? 'thumbnail.jpg' : 'no_selection';
61-
$childProduct->expects($this->any())->method('getThumbnail')->will($this->returnValue($childThumbnail));
62-
63-
/** Mock methods which return parent and child products */
64-
/** @var \Magento\Quote\Model\Quote\Item\Option|\PHPUnit_Framework_MockObject_MockObject $itemOption */
65-
$itemOption = $this->createMock(\Magento\Quote\Model\Quote\Item\Option::class);
66-
$itemOption->expects($this->any())->method('getProduct')->will($this->returnValue($parentProduct));
67-
/** @var \Magento\Quote\Model\Quote\Item|\PHPUnit_Framework_MockObject_MockObject $item */
68-
$item = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
69-
$item->expects($this->any())->method('getProduct')->will($this->returnValue($childProduct));
70-
$item->expects(
71-
$this->any()
72-
)->method(
73-
'getOptionByCode'
74-
)->with(
75-
'product_type'
76-
)->will(
77-
$this->returnValue($itemOption)
78-
);
79-
$this->_renderer->setItem($item);
80-
81-
return ['parentProduct' => $parentProduct, 'childProduct' => $childProduct];
82-
}
83-
8430
public function testGetIdentities()
8531
{
8632
$productTags = ['catalog_product_1'];
8733
$product = $this->createMock(\Magento\Catalog\Model\Product::class);
8834
$product->expects($this->exactly(2))->method('getIdentities')->will($this->returnValue($productTags));
8935
$item = $this->createMock(\Magento\Quote\Model\Quote\Item::class);
9036
$item->expects($this->exactly(2))->method('getProduct')->will($this->returnValue($product));
91-
$this->_renderer->setItem($item);
92-
$this->assertEquals(array_merge($productTags, $productTags), $this->_renderer->getIdentities());
37+
$this->renderer->setItem($item);
38+
$this->assertEquals(array_merge($productTags, $productTags), $this->renderer->getIdentities());
9339
}
9440
}

app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Image.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
/**
88
* Wishlist block customer item cart column
9-
*
10-
* @author Magento Core Team <[email protected]>
119
*/
1210
namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column;
1311

0 commit comments

Comments
 (0)