1313use Magento \Customer \Api \Data \CustomerInterfaceFactory ;
1414use Magento \Customer \Api \Data \GroupInterface ;
1515use Magento \Customer \Api \GroupManagementInterface ;
16- use Magento \Customer \Helper \Address ;
16+ use Magento \Customer \Helper \Address as CustomerAddress ;
1717use Magento \Customer \Model \Session ;
1818use Magento \Customer \Model \Vat ;
1919use Magento \Framework \Event \Observer ;
2020use Magento \Framework \TestFramework \Unit \Helper \ObjectManager ;
2121use Magento \Quote \Api \Data \ShippingAssignmentInterface ;
2222use Magento \Quote \Api \Data \ShippingInterface ;
2323use Magento \Quote \Model \Quote ;
24+ use Magento \Quote \Model \Quote \Address ;
2425use Magento \Quote \Observer \Frontend \Quote \Address \CollectTotalsObserver ;
2526use Magento \Quote \Observer \Frontend \Quote \Address \VatValidator ;
26- use PHPUnit \Framework \MockObject \MockObject ;
2727use PHPUnit \Framework \TestCase ;
28+ use PHPUnit \Framework \MockObject \MockObject ;
2829
2930/**
3031 * Class CollectTotalsTest
@@ -124,7 +125,7 @@ protected function setUp(): void
124125 true ,
125126 ['getStoreId ' , 'getCustomAttribute ' , 'getId ' , '__wakeup ' ]
126127 );
127- $ this ->customerAddressMock = $ this ->createMock (Address ::class);
128+ $ this ->customerAddressMock = $ this ->createMock (CustomerAddress ::class);
128129 $ this ->customerVatMock = $ this ->createMock (Vat::class);
129130 $ this ->customerDataFactoryMock = $ this ->getMockBuilder (CustomerInterfaceFactory::class)
130131 ->addMethods (['mergeDataObjectWithArray ' ])
@@ -174,6 +175,7 @@ protected function setUp(): void
174175
175176 $ shippingAssignmentMock = $ this ->getMockForAbstractClass (ShippingAssignmentInterface::class);
176177 $ shippingMock = $ this ->getMockForAbstractClass (ShippingInterface::class);
178+
177179 $ shippingAssignmentMock ->expects ($ this ->once ())->method ('getShipping ' )->willReturn ($ shippingMock );
178180 $ shippingMock ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->quoteAddressMock );
179181
@@ -185,7 +187,6 @@ protected function setUp(): void
185187 $ this ->quoteMock ->expects ($ this ->any ())
186188 ->method ('getCustomer ' )
187189 ->willReturn ($ this ->customerMock );
188-
189190 $ this ->addressRepository = $ this ->getMockForAbstractClass (AddressRepositoryInterface::class);
190191 $ this ->customerSession = $ this ->getMockBuilder (Session::class)
191192 ->disableOriginalConstructor ()
@@ -266,26 +267,20 @@ public function testDispatchWithDefaultCustomerGroupId()
266267 ->willReturn ('customerCountryCode ' );
267268 $ this ->quoteAddressMock ->expects ($ this ->once ())->method ('getVatId ' )->willReturn (null );
268269
269- $ this ->quoteMock ->expects ($ this ->once ( ))
270+ $ this ->quoteMock ->expects ($ this ->exactly ( 2 ))
270271 ->method ('getCustomerGroupId ' )
271272 ->willReturn ('customerGroupId ' );
272273 $ 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+
278275 /** Assertions */
279276 $ this ->quoteAddressMock ->expects ($ this ->once ())
280277 ->method ('setPrevQuoteCustomerGroupId ' )
281278 ->with ('customerGroupId ' );
282- $ this ->quoteMock ->expects ($ this ->once ())->method ('setCustomerGroupId ' )->with ('defaultCustomerGroupId ' );
283279 $ this ->customerDataFactoryMock ->expects ($ this ->any ())
284280 ->method ('create ' )
285281 ->willReturn ($ this ->customerMock );
286282
287283 $ this ->quoteMock ->expects ($ this ->once ())->method ('setCustomer ' )->with ($ this ->customerMock );
288-
289284 /** SUT execution */
290285 $ this ->model ->execute ($ this ->observerMock );
291286 }
@@ -343,7 +338,7 @@ public function testDispatchWithAddressCustomerVatIdAndCountryId()
343338 $ customerVat = "123123123 " ;
344339 $ defaultShipping = 1 ;
345340
346- $ customerAddress = $ this ->createMock (\ Magento \ Quote \ Model \ Quote \ Address::class);
341+ $ customerAddress = $ this ->createMock (Address::class);
347342 $ customerAddress ->expects ($ this ->any ())
348343 ->method ("getVatId " )
349344 ->willReturn ($ customerVat );
@@ -379,8 +374,8 @@ public function testDispatchWithEmptyShippingAddress()
379374 $ customerCountryCode = "DE " ;
380375 $ customerVat = "123123123 " ;
381376 $ defaultShipping = 1 ;
382-
383377 $ customerAddress = $ this ->getMockForAbstractClass (AddressInterface::class);
378+
384379 $ customerAddress ->expects ($ this ->once ())
385380 ->method ("getCountryId " )
386381 ->willReturn ($ customerCountryCode );
0 commit comments