20
20
use Magento \Quote \Model \Quote \Address ;
21
21
use Magento \Quote \Model \Quote \Item as QuoteItem ;
22
22
use Magento \Quote \Model \Cart \TotalsConverter ;
23
+ use Magento \Quote \Api \Data \TotalsInterfaceFactory ;
24
+ use Magento \Quote \Api \Data \TotalsInterface as QuoteTotalsInterface ;
23
25
use PHPUnit \Framework \TestCase ;
24
26
use PHPUnit \Framework \MockObject \MockObject ;
25
27
30
32
*/
31
33
class CartTotalRepositoryTest extends TestCase
32
34
{
33
- /**
34
- * @var int
35
- */
36
35
private const STUB_CART_ID = 12 ;
37
36
38
- /**
39
- * @var int
40
- */
41
37
private const STUB_ITEMS_QTY = 100 ;
42
38
43
- /**
44
- * @var string
45
- */
46
39
private const STUB_CURRENCY_CODE = 'en_US ' ;
47
40
48
- /**
49
- * @var string
50
- */
51
41
private const STUB_COUPON = 'coupon ' ;
52
42
53
43
/**
@@ -76,7 +66,7 @@ class CartTotalRepositoryTest extends TestCase
76
66
private $ quoteMock ;
77
67
78
68
/**
79
- * @var \Magento\Quote\Api\Data\ TotalsInterfaceFactory|MockObject
69
+ * @var TotalsInterfaceFactory|MockObject
80
70
*/
81
71
private $ totalsFactoryMock ;
82
72
@@ -104,10 +94,14 @@ protected function setUp()
104
94
{
105
95
$ this ->objectManager = new ObjectManagerHelper ($ this );
106
96
$ this ->totalsFactoryMock = $ this ->createPartialMock (
107
- \Magento \Quote \Api \Data \TotalsInterfaceFactory::class,
108
- ['create ' ]
97
+ TotalsInterfaceFactory::class,
98
+ [
99
+ 'create '
100
+ ]
109
101
);
110
- $ this ->quoteMock = $ this ->createPartialMock (Quote::class, [
102
+ $ this ->quoteMock = $ this ->createPartialMock (
103
+ Quote::class,
104
+ [
111
105
'isVirtual ' ,
112
106
'getShippingAddress ' ,
113
107
'getBillingAddress ' ,
@@ -116,19 +110,31 @@ protected function setUp()
116
110
'getQuoteCurrencyCode ' ,
117
111
'getItemsQty ' ,
118
112
'collectTotals '
119
- ]);
120
- $ this ->quoteRepositoryMock = $ this ->createMock (CartRepositoryInterface::class);
113
+ ]
114
+ );
115
+ $ this ->quoteRepositoryMock = $ this ->createMock (
116
+ CartRepositoryInterface::class
117
+ );
121
118
$ this ->addressMock = $ this ->createPartialMock (
122
119
Address::class,
123
- ['getData ' , 'getTotals ' ]
120
+ [
121
+ 'getData ' ,
122
+ 'getTotals '
123
+ ]
124
+ );
125
+ $ this ->dataObjectHelperMock = $ this ->getMockBuilder (
126
+ DataObjectHelper::class
127
+ )->disableOriginalConstructor ()->getMock ();
128
+ $ this ->converterMock = $ this ->createMock (
129
+ ItemConverter::class
124
130
);
125
- $ this ->dataObjectHelperMock = $ this ->getMockBuilder (DataObjectHelper::class)
126
- ->disableOriginalConstructor ()
127
- ->getMock ();
128
- $ this ->converterMock = $ this ->createMock (ItemConverter::class);
129
131
130
- $ this ->couponServiceMock = $ this ->createMock (CouponManagementInterface::class);
131
- $ this ->totalsConverterMock = $ this ->createMock (TotalsConverter::class);
132
+ $ this ->couponServiceMock = $ this ->createMock (
133
+ CouponManagementInterface::class
134
+ );
135
+ $ this ->totalsConverterMock = $ this ->createMock (
136
+ TotalsConverter::class
137
+ );
132
138
133
139
$ this ->model = new CartTotalRepository (
134
140
$ this ->totalsFactoryMock ,
@@ -189,8 +195,10 @@ public function testGetCartTotal($isVirtual, $getAddressType): void
189
195
->method ('getTotals ' )
190
196
->willReturn ($ addressTotals );
191
197
192
- $ totalsMock = $ this ->createMock (\Magento \Quote \Api \Data \TotalsInterface::class);
193
- $ this ->totalsFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ totalsMock );
198
+ $ totalsMock = $ this ->createMock (QuoteTotalsInterface::class);
199
+ $ this ->totalsFactoryMock ->expects ($ this ->once ())
200
+ ->method ('create ' )
201
+ ->willReturn ($ totalsMock );
194
202
$ this ->dataObjectHelperMock ->expects ($ this ->once ())->method ('populateWithArray ' );
195
203
$ this ->converterMock ->expects ($ this ->once ())
196
204
->method ('modelToDataObject ' )
0 commit comments