11
11
class ConfigurableTest extends \PHPUnit \Framework \TestCase
12
12
{
13
13
/** @var \Magento\Framework\View\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
14
- protected $ _configManager ;
14
+ private $ configManager ;
15
15
16
16
/** @var \Magento\Catalog\Helper\Image|\PHPUnit_Framework_MockObject_MockObject */
17
- protected $ _imageHelper ;
17
+ private $ imageHelper ;
18
18
19
19
/** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
20
- protected $ _scopeConfig ;
20
+ private $ scopeConfig ;
21
21
22
22
/** @var \PHPUnit_Framework_MockObject_MockObject */
23
- protected $ productConfigMock ;
23
+ private $ productConfigMock ;
24
24
25
25
/** @var Renderer */
26
- protected $ _renderer ;
26
+ private $ renderer ;
27
27
28
28
protected function setUp ()
29
29
{
30
30
parent ::setUp ();
31
31
$ 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 (
34
34
\Magento \Catalog \Helper \Image::class,
35
35
['init ' , 'resize ' , '__toString ' ]
36
36
);
37
- $ this ->_scopeConfig = $ this ->createMock (\Magento \Framework \App \Config \ScopeConfigInterface::class);
37
+ $ this ->scopeConfig = $ this ->createMock (\Magento \Framework \App \Config \ScopeConfigInterface::class);
38
38
$ this ->productConfigMock = $ this ->createMock (\Magento \Catalog \Helper \Product \Configuration::class);
39
- $ this ->_renderer = $ objectManagerHelper ->getObject (
39
+ $ this ->renderer = $ objectManagerHelper ->getObject (
40
40
\Magento \ConfigurableProduct \Block \Cart \Item \Renderer \Configurable::class,
41
41
[
42
- 'viewConfig ' => $ this ->_configManager ,
43
- 'imageHelper ' => $ this ->_imageHelper ,
44
- 'scopeConfig ' => $ this ->_scopeConfig ,
42
+ 'viewConfig ' => $ this ->configManager ,
43
+ 'imageHelper ' => $ this ->imageHelper ,
44
+ 'scopeConfig ' => $ this ->scopeConfig ,
45
45
'productConfig ' => $ this ->productConfigMock
46
46
]
47
47
);
48
48
}
49
49
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
-
104
50
public function testGetOptionList ()
105
51
{
106
52
$ itemMock = $ this ->createMock (\Magento \Quote \Model \Quote \Item::class);
107
- $ this ->_renderer ->setItem ($ itemMock );
53
+ $ this ->renderer ->setItem ($ itemMock );
108
54
$ this ->productConfigMock ->expects ($ this ->once ())->method ('getOptions ' )->with ($ itemMock );
109
- $ this ->_renderer ->getOptionList ();
55
+ $ this ->renderer ->getOptionList ();
110
56
}
111
57
112
58
public function testGetIdentities ()
@@ -116,7 +62,7 @@ public function testGetIdentities()
116
62
$ product ->expects ($ this ->exactly (2 ))->method ('getIdentities ' )->will ($ this ->returnValue ($ productTags ));
117
63
$ item = $ this ->createMock (\Magento \Quote \Model \Quote \Item::class);
118
64
$ 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 ());
121
67
}
122
68
}
0 commit comments