6
6
7
7
namespace Magento \Quote \Test \Unit \Observer \Frontend \Quote \Address ;
8
8
9
+ use Magento \Customer \Api \AddressRepositoryInterface ;
10
+ use Magento \Customer \Api \Data \AddressInterface ;
11
+ use Magento \Customer \Api \Data \CustomerInterface ;
12
+ use Magento \Customer \Api \Data \CustomerInterfaceFactory ;
13
+ use Magento \Customer \Api \Data \GroupInterface ;
14
+ use Magento \Customer \Api \GroupManagementInterface ;
15
+ use Magento \Customer \Model \Session ;
16
+ use Magento \Customer \Model \Vat ;
17
+ use Magento \Framework \Event \Observer ;
18
+ use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
19
+ use Magento \Quote \Api \Data \ShippingAssignmentInterface ;
20
+ use Magento \Quote \Api \Data \ShippingInterface ;
21
+ use Magento \Quote \Model \Quote ;
22
+ use Magento \Quote \Model \Quote \Address ;
23
+ use Magento \Quote \Observer \Frontend \Quote \Address \CollectTotalsObserver ;
24
+ use Magento \Quote \Observer \Frontend \Quote \Address \VatValidator ;
25
+ use PHPUnit \Framework \TestCase ;
26
+ use PHPUnit \Framework \MockObject \MockObject ;
27
+
9
28
/**
10
29
* Class CollectTotalsTest
11
30
*
12
31
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
13
32
*/
14
- class CollectTotalsObserverTest extends \ PHPUnit \ Framework \ TestCase
33
+ class CollectTotalsObserverTest extends TestCase
15
34
{
16
35
/**
17
- * @var \Magento\Quote\Observer\Frontend\Quote\Address\ CollectTotalsObserver
36
+ * @var CollectTotalsObserver
18
37
*/
19
38
protected $ model ;
20
39
21
40
/**
22
- * @var \PHPUnit_Framework_MockObject_MockObject
41
+ * @var MockObject
23
42
*/
24
43
protected $ customerAddressMock ;
25
44
26
45
/**
27
- * @var \PHPUnit_Framework_MockObject_MockObject
46
+ * @var MockObject
28
47
*/
29
48
protected $ customerSession ;
30
49
31
50
/**
32
- * @var \PHPUnit_Framework_MockObject_MockObject
51
+ * @var MockObject
33
52
*/
34
53
protected $ customerVatMock ;
35
54
36
55
/**
37
- * @var \PHPUnit_Framework_MockObject_MockObject
56
+ * @var MockObject
38
57
*/
39
58
protected $ addressRepository ;
40
59
41
60
/**
42
- * @var \PHPUnit_Framework_MockObject_MockObject
61
+ * @var MockObject
43
62
*/
44
63
protected $ quoteAddressMock ;
45
64
46
65
/**
47
- * @var \PHPUnit_Framework_MockObject_MockObject
66
+ * @var MockObject
48
67
*/
49
68
protected $ quoteMock ;
50
69
51
70
/**
52
- * @var \PHPUnit_Framework_MockObject_MockObject
71
+ * @var MockObject
53
72
*/
54
73
protected $ storeId ;
55
74
56
75
/**
57
- * @var \PHPUnit_Framework_MockObject_MockObject
76
+ * @var MockObject
58
77
*/
59
78
protected $ customerMock ;
60
79
61
80
/**
62
- * @var \PHPUnit_Framework_MockObject_MockObject
81
+ * @var MockObject
63
82
*/
64
83
protected $ vatValidatorMock ;
65
84
66
85
/**
67
- * @var \PHPUnit_Framework_MockObject_MockObject
86
+ * @var MockObject
68
87
*/
69
88
protected $ observerMock ;
70
89
71
90
/**
72
- * @var \PHPUnit_Framework_MockObject_MockObject
91
+ * @var MockObject
73
92
*/
74
93
protected $ customerDataFactoryMock ;
75
94
76
95
/**
77
- * @var \Magento\Framework\TestFramework\Unit\Helper\ ObjectManager
96
+ * @var ObjectManager
78
97
*/
79
98
protected $ objectManager ;
80
99
81
100
/**
82
- * @var \PHPUnit_Framework_MockObject_MockObject
101
+ * @var MockObject
83
102
*/
84
103
protected $ groupManagementMock ;
85
104
86
105
/**
87
- * @var \PHPUnit_Framework_MockObject_MockObject
106
+ * @var MockObject
88
107
*/
89
108
protected $ groupInterfaceMock ;
90
109
@@ -93,10 +112,10 @@ class CollectTotalsObserverTest extends \PHPUnit\Framework\TestCase
93
112
*/
94
113
protected function setUp ()
95
114
{
96
- $ this ->objectManager = new \ Magento \ Framework \ TestFramework \ Unit \ Helper \ ObjectManager ($ this );
115
+ $ this ->objectManager = new ObjectManager ($ this );
97
116
$ this ->storeId = 1 ;
98
117
$ this ->customerMock = $ this ->getMockForAbstractClass (
99
- \ Magento \ Customer \ Api \ Data \ CustomerInterface::class,
118
+ CustomerInterface::class,
100
119
[],
101
120
'' ,
102
121
false ,
@@ -105,29 +124,29 @@ protected function setUp()
105
124
['getStoreId ' , 'getCustomAttribute ' , 'getId ' , '__wakeup ' ]
106
125
);
107
126
$ this ->customerAddressMock = $ this ->createMock (\Magento \Customer \Helper \Address::class);
108
- $ this ->customerVatMock = $ this ->createMock (\ Magento \ Customer \ Model \ Vat::class);
127
+ $ this ->customerVatMock = $ this ->createMock (Vat::class);
109
128
$ this ->customerDataFactoryMock = $ this ->createPartialMock (
110
- \ Magento \ Customer \ Api \ Data \ CustomerInterfaceFactory::class,
129
+ CustomerInterfaceFactory::class,
111
130
['mergeDataObjectWithArray ' , 'create ' ]
112
131
);
113
- $ this ->vatValidatorMock = $ this ->createMock (\ Magento \ Quote \ Observer \ Frontend \ Quote \ Address \ VatValidator::class);
132
+ $ this ->vatValidatorMock = $ this ->createMock (VatValidator::class);
114
133
$ this ->observerMock = $ this ->createPartialMock (
115
- \ Magento \ Framework \ Event \ Observer::class,
134
+ Observer::class,
116
135
['getShippingAssignment ' , 'getQuote ' ]
117
136
);
118
137
119
138
$ this ->quoteAddressMock = $ this ->createPartialMock (
120
- \ Magento \ Quote \ Model \ Quote \ Address::class,
139
+ Address::class,
121
140
['getCountryId ' , 'getVatId ' , 'getQuote ' , 'setPrevQuoteCustomerGroupId ' , '__wakeup ' ]
122
141
);
123
142
124
143
$ this ->quoteMock = $ this ->createPartialMock (
125
- \ Magento \ Quote \ Model \ Quote::class,
144
+ Quote::class,
126
145
['setCustomerGroupId ' , 'getCustomerGroupId ' , 'getCustomer ' , '__wakeup ' , 'setCustomer ' ]
127
146
);
128
147
129
148
$ this ->groupManagementMock = $ this ->getMockForAbstractClass (
130
- \ Magento \ Customer \ Api \ GroupManagementInterface::class,
149
+ GroupManagementInterface::class,
131
150
[],
132
151
'' ,
133
152
false ,
@@ -140,7 +159,7 @@ protected function setUp()
140
159
);
141
160
142
161
$ this ->groupInterfaceMock = $ this ->getMockForAbstractClass (
143
- \ Magento \ Customer \ Api \ Data \ GroupInterface::class,
162
+ GroupInterface::class,
144
163
[],
145
164
'' ,
146
165
false ,
@@ -149,8 +168,8 @@ protected function setUp()
149
168
['getId ' ]
150
169
);
151
170
152
- $ shippingAssignmentMock = $ this ->createMock (\ Magento \ Quote \ Api \ Data \ ShippingAssignmentInterface::class);
153
- $ shippingMock = $ this ->createMock (\ Magento \ Quote \ Api \ Data \ ShippingInterface::class);
171
+ $ shippingAssignmentMock = $ this ->createMock (ShippingAssignmentInterface::class);
172
+ $ shippingMock = $ this ->createMock (ShippingInterface::class);
154
173
$ shippingAssignmentMock ->expects ($ this ->once ())->method ('getShipping ' )->willReturn ($ shippingMock );
155
174
$ shippingMock ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->quoteAddressMock );
156
175
@@ -163,14 +182,14 @@ protected function setUp()
163
182
->method ('getCustomer ' )
164
183
->will ($ this ->returnValue ($ this ->customerMock ));
165
184
166
- $ this ->addressRepository = $ this ->createMock (\ Magento \ Customer \ Api \ AddressRepositoryInterface::class);
167
- $ this ->customerSession = $ this ->getMockBuilder (\ Magento \ Customer \ Model \ Session::class)
185
+ $ this ->addressRepository = $ this ->createMock (AddressRepositoryInterface::class);
186
+ $ this ->customerSession = $ this ->getMockBuilder (Session::class)
168
187
->disableOriginalConstructor ()
169
188
->getMock ();
170
189
171
190
$ this ->customerMock ->expects ($ this ->any ())->method ('getStoreId ' )->will ($ this ->returnValue ($ this ->storeId ));
172
191
173
- $ this ->model = new \ Magento \ Quote \ Observer \ Frontend \ Quote \ Address \ CollectTotalsObserver (
192
+ $ this ->model = new CollectTotalsObserver (
174
193
$ this ->customerAddressMock ,
175
194
$ this ->customerVatMock ,
176
195
$ this ->vatValidatorMock ,
@@ -313,7 +332,7 @@ public function testDispatchWithAddressCustomerVatIdAndCountryId()
313
332
$ customerVat = "123123123 " ;
314
333
$ defaultShipping = 1 ;
315
334
316
- $ customerAddress = $ this ->createMock (\ Magento \ Quote \ Model \ Quote \ Address::class);
335
+ $ customerAddress = $ this ->createMock (Address::class);
317
336
$ customerAddress ->expects ($ this ->any ())
318
337
->method ("getVatId " )
319
338
->willReturn ($ customerVat );
@@ -350,7 +369,7 @@ public function testDispatchWithEmptyShippingAddress()
350
369
$ customerVat = "123123123 " ;
351
370
$ defaultShipping = 1 ;
352
371
353
- $ customerAddress = $ this ->createMock (\ Magento \ Customer \ Api \ Data \ AddressInterface::class);
372
+ $ customerAddress = $ this ->createMock (AddressInterface::class);
354
373
$ customerAddress ->expects ($ this ->once ())
355
374
->method ("getCountryId " )
356
375
->willReturn ($ customerCountryCode );
0 commit comments