13
13
use Magento \Customer \Api \Data \CustomerInterfaceFactory ;
14
14
use Magento \Customer \Api \Data \GroupInterface ;
15
15
use Magento \Customer \Api \GroupManagementInterface ;
16
- use Magento \Customer \Helper \Address ;
16
+ use Magento \Customer \Helper \Address as CustomerAddress ;
17
17
use Magento \Customer \Model \Session ;
18
18
use Magento \Customer \Model \Vat ;
19
19
use Magento \Framework \Event \Observer ;
20
20
use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
21
21
use Magento \Quote \Api \Data \ShippingAssignmentInterface ;
22
22
use Magento \Quote \Api \Data \ShippingInterface ;
23
23
use Magento \Quote \Model \Quote ;
24
+ use Magento \Quote \Model \Quote \Address ;
24
25
use Magento \Quote \Observer \Frontend \Quote \Address \CollectTotalsObserver ;
25
26
use Magento \Quote \Observer \Frontend \Quote \Address \VatValidator ;
26
- use PHPUnit \Framework \MockObject \MockObject ;
27
27
use PHPUnit \Framework \TestCase ;
28
+ use PHPUnit \Framework \MockObject \MockObject ;
28
29
29
30
/**
30
31
* Class CollectTotalsTest
@@ -124,7 +125,7 @@ protected function setUp(): void
124
125
true ,
125
126
['getStoreId ' , 'getCustomAttribute ' , 'getId ' , '__wakeup ' ]
126
127
);
127
- $ this ->customerAddressMock = $ this ->createMock (Address ::class);
128
+ $ this ->customerAddressMock = $ this ->createMock (CustomerAddress ::class);
128
129
$ this ->customerVatMock = $ this ->createMock (Vat::class);
129
130
$ this ->customerDataFactoryMock = $ this ->getMockBuilder (CustomerInterfaceFactory::class)
130
131
->addMethods (['mergeDataObjectWithArray ' ])
@@ -174,6 +175,7 @@ protected function setUp(): void
174
175
175
176
$ shippingAssignmentMock = $ this ->getMockForAbstractClass (ShippingAssignmentInterface::class);
176
177
$ shippingMock = $ this ->getMockForAbstractClass (ShippingInterface::class);
178
+
177
179
$ shippingAssignmentMock ->expects ($ this ->once ())->method ('getShipping ' )->willReturn ($ shippingMock );
178
180
$ shippingMock ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->quoteAddressMock );
179
181
@@ -185,7 +187,6 @@ protected function setUp(): void
185
187
$ this ->quoteMock ->expects ($ this ->any ())
186
188
->method ('getCustomer ' )
187
189
->willReturn ($ this ->customerMock );
188
-
189
190
$ this ->addressRepository = $ this ->getMockForAbstractClass (AddressRepositoryInterface::class);
190
191
$ this ->customerSession = $ this ->getMockBuilder (Session::class)
191
192
->disableOriginalConstructor ()
@@ -266,26 +267,20 @@ public function testDispatchWithDefaultCustomerGroupId()
266
267
->willReturn ('customerCountryCode ' );
267
268
$ this ->quoteAddressMock ->expects ($ this ->once ())->method ('getVatId ' )->willReturn (null );
268
269
269
- $ this ->quoteMock ->expects ($ this ->once ( ))
270
+ $ this ->quoteMock ->expects ($ this ->exactly ( 2 ))
270
271
->method ('getCustomerGroupId ' )
271
272
->willReturn ('customerGroupId ' );
272
273
$ this ->customerMock ->expects ($ this ->once ())->method ('getId ' )->willReturn ('1 ' );
273
- $ this ->groupManagementMock ->expects ($ this ->once ())
274
- ->method ('getDefaultGroup ' )
275
- ->willReturn ($ this ->groupInterfaceMock );
276
- $ this ->groupInterfaceMock ->expects ($ this ->once ())
277
- ->method ('getId ' )->willReturn ('defaultCustomerGroupId ' );
274
+
278
275
/** Assertions */
279
276
$ this ->quoteAddressMock ->expects ($ this ->once ())
280
277
->method ('setPrevQuoteCustomerGroupId ' )
281
278
->with ('customerGroupId ' );
282
- $ this ->quoteMock ->expects ($ this ->once ())->method ('setCustomerGroupId ' )->with ('defaultCustomerGroupId ' );
283
279
$ this ->customerDataFactoryMock ->expects ($ this ->any ())
284
280
->method ('create ' )
285
281
->willReturn ($ this ->customerMock );
286
282
287
283
$ this ->quoteMock ->expects ($ this ->once ())->method ('setCustomer ' )->with ($ this ->customerMock );
288
-
289
284
/** SUT execution */
290
285
$ this ->model ->execute ($ this ->observerMock );
291
286
}
@@ -343,7 +338,7 @@ public function testDispatchWithAddressCustomerVatIdAndCountryId()
343
338
$ customerVat = "123123123 " ;
344
339
$ defaultShipping = 1 ;
345
340
346
- $ customerAddress = $ this ->createMock (\ Magento \ Quote \ Model \ Quote \ Address::class);
341
+ $ customerAddress = $ this ->createMock (Address::class);
347
342
$ customerAddress ->expects ($ this ->any ())
348
343
->method ("getVatId " )
349
344
->willReturn ($ customerVat );
@@ -379,8 +374,8 @@ public function testDispatchWithEmptyShippingAddress()
379
374
$ customerCountryCode = "DE " ;
380
375
$ customerVat = "123123123 " ;
381
376
$ defaultShipping = 1 ;
382
-
383
377
$ customerAddress = $ this ->getMockForAbstractClass (AddressInterface::class);
378
+
384
379
$ customerAddress ->expects ($ this ->once ())
385
380
->method ("getCountryId " )
386
381
->willReturn ($ customerCountryCode );
0 commit comments