5
5
*/
6
6
namespace Magento \ConfigurableProduct \Test \Unit \Pricing \Render ;
7
7
8
+ use Magento \Catalog \Model \Product ;
9
+ use Magento \Catalog \Model \Product \Pricing \Renderer \SalableResolverInterface ;
8
10
use Magento \Catalog \Pricing \Price \FinalPrice ;
11
+ use Magento \Catalog \Pricing \Price \MinimalPriceCalculatorInterface ;
9
12
use Magento \Catalog \Pricing \Price \RegularPrice ;
10
- use Magento \ConfigurableProduct \Pricing \Price \LowestPriceOptionsProviderInterface ;
13
+ use Magento \ConfigurableProduct \Pricing \Price \ConfigurableOptionsProviderInterface ;
11
14
use Magento \ConfigurableProduct \Pricing \Render \FinalPriceBox ;
15
+ use Magento \Framework \Pricing \Price \PriceInterface ;
16
+ use Magento \Framework \Pricing \PriceInfoInterface ;
17
+ use Magento \Framework \Pricing \Render \RendererPool ;
12
18
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
19
+ use Magento \Framework \View \Element \Template \Context ;
20
+ use PHPUnit \Framework \MockObject \MockObject ;
13
21
14
22
class FinalPriceBoxTest extends \PHPUnit \Framework \TestCase
15
23
{
16
24
/**
17
- * @var \Magento\Framework\View\Element\Template\ Context|\PHPUnit_Framework_MockObject_MockObject
25
+ * @var Context|MockObject
18
26
*/
19
27
private $ context ;
20
28
21
29
/**
22
- * @var \Magento\Catalog\Model\ Product|\PHPUnit_Framework_MockObject_MockObject
30
+ * @var Product|MockObject
23
31
*/
24
32
private $ saleableItem ;
25
33
26
34
/**
27
- * @var \Magento\Framework\Pricing\Price\ PriceInterface|\PHPUnit_Framework_MockObject_MockObject
35
+ * @var PriceInterface|MockObject
28
36
*/
29
37
private $ price ;
30
38
31
39
/**
32
- * @var \Magento\Framework\Pricing\Render\ RendererPool|\PHPUnit_Framework_MockObject_MockObject
40
+ * @var RendererPool|MockObject
33
41
*/
34
42
private $ rendererPool ;
35
43
36
44
/**
37
- * @var LowestPriceOptionsProviderInterface|\PHPUnit_Framework_MockObject_MockObject
45
+ * @var SalableResolverInterface|MockObject
38
46
*/
39
- private $ lowestPriceOptionsProvider ;
47
+ private $ salableResolver ;
48
+
49
+ /**
50
+ * @var MinimalPriceCalculatorInterface|MockObject
51
+ */
52
+ private $ minimalPriceCalculator ;
53
+
54
+ /**
55
+ * @var ConfigurableOptionsProviderInterface|MockObject
56
+ */
57
+ private $ configurableOptionsProvider ;
40
58
41
59
/**
42
60
* @var FinalPriceBox
43
61
*/
44
62
private $ model ;
45
63
64
+ /**
65
+ * @inheritDoc
66
+ */
46
67
protected function setUp ()
47
68
{
48
- $ this ->context = $ this ->getMockBuilder (\Magento \Framework \View \Element \Template \Context::class)
49
- ->disableOriginalConstructor ()
50
- ->getMock ();
51
-
52
- $ this ->saleableItem = $ this ->getMockBuilder (\Magento \Catalog \Model \Product::class)
53
- ->disableOriginalConstructor ()
54
- ->getMock ();
55
-
56
- $ this ->price = $ this ->getMockBuilder (\Magento \Framework \Pricing \Price \PriceInterface::class)
57
- ->getMockForAbstractClass ();
58
-
59
- $ this ->rendererPool = $ this ->getMockBuilder (\Magento \Framework \Pricing \Render \RendererPool::class)
60
- ->disableOriginalConstructor ()
61
- ->getMock ();
62
-
63
- $ this ->lowestPriceOptionsProvider = $ this ->getMockBuilder (LowestPriceOptionsProviderInterface::class)
64
- ->getMockForAbstractClass ();
69
+ $ this ->context = $ this ->createMock (Context::class);
70
+ $ this ->saleableItem = $ this ->createMock (Product::class);
71
+ $ this ->price = $ this ->createMock (PriceInterface::class);
72
+ $ this ->rendererPool = $ this ->createMock (RendererPool::class);
73
+ $ this ->salableResolver = $ this ->createMock (SalableResolverInterface::class);
74
+ $ this ->minimalPriceCalculator = $ this ->createMock (MinimalPriceCalculatorInterface::class);
75
+ $ this ->configurableOptionsProvider = $ this ->createMock (ConfigurableOptionsProviderInterface::class);
65
76
66
77
$ this ->model = (new ObjectManager ($ this ))->getObject (
67
78
FinalPriceBox::class,
@@ -70,7 +81,9 @@ protected function setUp()
70
81
'saleableItem ' => $ this ->saleableItem ,
71
82
'price ' => $ this ->price ,
72
83
'rendererPool ' => $ this ->rendererPool ,
73
- 'lowestPriceOptionsProvider ' => $ this ->lowestPriceOptionsProvider ,
84
+ 'salableResolver ' => $ this ->salableResolver ,
85
+ 'minimalPriceCalculator ' => $ this ->minimalPriceCalculator ,
86
+ 'configurableOptionsProvider ' => $ this ->configurableOptionsProvider ,
74
87
]
75
88
);
76
89
}
@@ -82,44 +95,31 @@ protected function setUp()
82
95
* @dataProvider hasSpecialPriceDataProvider
83
96
*/
84
97
public function testHasSpecialPrice (
85
- $ regularPrice ,
86
- $ finalPrice ,
87
- $ expected
98
+ float $ regularPrice ,
99
+ float $ finalPrice ,
100
+ bool $ expected
88
101
) {
89
- $ priceMockOne = $ this ->getMockBuilder (\Magento \Framework \Pricing \Price \PriceInterface::class)
90
- ->getMockForAbstractClass ();
91
-
102
+ $ priceMockOne = $ this ->createMock (PriceInterface::class);
92
103
$ priceMockOne ->expects ($ this ->once ())
93
104
->method ('getValue ' )
94
105
->willReturn ($ regularPrice );
95
-
96
- $ priceMockTwo = $ this ->getMockBuilder (\Magento \Framework \Pricing \Price \PriceInterface::class)
97
- ->getMockForAbstractClass ();
98
-
106
+ $ priceMockTwo = $ this ->createMock (PriceInterface::class);
99
107
$ priceMockTwo ->expects ($ this ->once ())
100
108
->method ('getValue ' )
101
109
->willReturn ($ finalPrice );
102
-
103
- $ priceInfoMock = $ this ->getMockBuilder (\Magento \Framework \Pricing \PriceInfo \Base::class)
104
- ->disableOriginalConstructor ()
105
- ->getMock ();
106
-
110
+ $ priceInfoMock = $ this ->createMock (PriceInfoInterface::class);
107
111
$ priceInfoMock ->expects ($ this ->exactly (2 ))
108
112
->method ('getPrice ' )
109
113
->willReturnMap ([
110
114
[RegularPrice::PRICE_CODE , $ priceMockOne ],
111
115
[FinalPrice::PRICE_CODE , $ priceMockTwo ],
112
116
]);
113
117
114
- $ productMock = $ this ->getMockBuilder (\Magento \Catalog \Api \Data \ProductInterface::class)
115
- ->setMethods (['getPriceInfo ' ])
116
- ->getMockForAbstractClass ();
117
-
118
+ $ productMock = $ this ->createMock (Product::class);
118
119
$ productMock ->expects ($ this ->exactly (2 ))
119
120
->method ('getPriceInfo ' )
120
121
->willReturn ($ priceInfoMock );
121
-
122
- $ this ->lowestPriceOptionsProvider ->expects ($ this ->once ())
122
+ $ this ->configurableOptionsProvider ->expects ($ this ->once ())
123
123
->method ('getProducts ' )
124
124
->with ($ this ->saleableItem )
125
125
->willReturn ([$ productMock ]);
@@ -130,7 +130,7 @@ public function testHasSpecialPrice(
130
130
/**
131
131
* @return array
132
132
*/
133
- public function hasSpecialPriceDataProvider ()
133
+ public function hasSpecialPriceDataProvider (): array
134
134
{
135
135
return [
136
136
[10. , 20. , false ],
0 commit comments