9
9
namespace Magento \Msrp \Test \Unit \Pricing ;
10
10
11
11
use Magento \Catalog \Model \Product ;
12
- use Magento \Catalog \Model \Product \Type as Type ;
12
+ use Magento \Catalog \Model \Product \Type as ProductType ;
13
13
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
14
14
use Magento \GroupedProduct \Model \Product \Type \Grouped as GroupedType ;
15
15
use Magento \Msrp \Pricing \MsrpPriceCalculator ;
19
19
20
20
class MsrpPriceCalculatorTest extends TestCase
21
21
{
22
+ /**
23
+ * @var MsrpPriceCalculator
24
+ */
25
+ private $ pricing ;
26
+
27
+ /**
28
+ * @var MsrpGroupedCalculator|MockObject
29
+ */
30
+ private $ msrpGroupedCalculatorMock ;
31
+
32
+ /**
33
+ * Prepare environment to test
34
+ */
35
+ protected function setUp ()
36
+ {
37
+ $ objectManager = new ObjectManager ($ this );
38
+ $ this ->msrpGroupedCalculatorMock = $ this ->createMock (MsrpGroupedCalculator::class);
39
+ $ this ->pricing = $ objectManager ->getObject (
40
+ MsrpPriceCalculator::class,
41
+ [
42
+ 'msrpPriceCalculators ' => [
43
+ [
44
+ 'productType ' => GroupedType::TYPE_CODE ,
45
+ 'priceCalculator ' => $ this ->msrpGroupedCalculatorMock
46
+ ]
47
+ ]
48
+ ]
49
+ );
50
+ }
51
+
22
52
/**
23
53
* Test getMrspPriceValue() with the data provider below
24
54
*
@@ -27,17 +57,12 @@ class MsrpPriceCalculatorTest extends TestCase
27
57
* @param float $expected
28
58
* @dataProvider getMsrpPriceValueDataProvider
29
59
*/
30
- public function testGetMsrpPriceValue ($ msrpPriceCalculators , $ productMock , $ expected )
60
+ public function testGetMsrpPriceValue ($ msrpPriceCalculatorPrice , $ productMock , $ expected )
31
61
{
32
- $ objectManager = new ObjectManager ($ this );
33
- $ pricing = $ objectManager ->getObject (
34
- MsrpPriceCalculator::class,
35
- [
36
- 'msrpPriceCalculators ' => $ msrpPriceCalculators
37
- ]
38
- );
62
+ $ this ->msrpGroupedCalculatorMock ->expects ($ this ->any ())
63
+ ->method ('getMsrpPriceValue ' )->willReturn ($ msrpPriceCalculatorPrice );
39
64
40
- $ this ->assertEquals ($ expected , $ pricing ->getMsrpPriceValue ($ productMock ));
65
+ $ this ->assertEquals ($ expected , $ this -> pricing ->getMsrpPriceValue ($ productMock ));
41
66
}
42
67
43
68
/**
@@ -48,49 +73,19 @@ public function testGetMsrpPriceValue($msrpPriceCalculators, $productMock, $expe
48
73
public function getMsrpPriceValueDataProvider ()
49
74
{
50
75
return [
51
- 'Get Mrsp Price with grouped product and price calculator is also grouped product type ' => [
52
- [
53
- [
54
- 'productType ' => GroupedType::TYPE_CODE ,
55
- 'priceCalculator ' => $ this ->createPriceCalculatorMock (
56
- MsrpGroupedCalculator::class,
57
- 23.50
58
- )
59
- ]
60
- ],
76
+ 'Get Mrsp Price with product and msrp calculator and the same product type ' => [
77
+ 23.50 ,
61
78
$ this ->createProductMock (GroupedType::TYPE_CODE , 0 ),
62
79
23.50
63
80
],
64
- 'Get Mrsp Price with simple product and price calculator is grouped product type ' => [
65
- [
66
- [
67
- 'productType ' => GroupedType::TYPE_CODE ,
68
- 'priceCalculator ' => $ this ->createPriceCalculatorMock (
69
- MsrpGroupedCalculator::class,
70
- 0
71
- )
72
- ]
73
- ],
74
- $ this ->createProductMock (Type::TYPE_SIMPLE , 24.88 ),
81
+ 'Get Mrsp Price with product and msrp calculator and the different product type ' => [
82
+ 24.88 ,
83
+ $ this ->createProductMock (ProductType::TYPE_SIMPLE , 24.88 ),
75
84
24.88
76
85
]
77
86
];
78
87
}
79
88
80
- /**
81
- * Create Price Calculator Mock
82
- *
83
- * @param string $class
84
- * @param float $msrpPriceValue
85
- * @return MockObject
86
- */
87
- private function createPriceCalculatorMock ($ class , $ msrpPriceValue )
88
- {
89
- $ priceCalculatorMock = $ this ->createMock ($ class );
90
- $ priceCalculatorMock ->expects ($ this ->any ())->method ('getMsrpPriceValue ' )->willReturn ($ msrpPriceValue );
91
- return $ priceCalculatorMock ;
92
- }
93
-
94
89
/**
95
90
* Create Product Mock
96
91
*
0 commit comments