@@ -314,6 +314,43 @@ public function testDispatchWithCustomerCountryInEU()
314
314
$ this ->model ->execute ($ this ->observerMock );
315
315
}
316
316
317
+ public function testDispatchWithAddressCustomerVatIdAndCountryId ()
318
+ {
319
+ $ customerCountryCode = "BE " ;
320
+ $ customerVat = "123123123 " ;
321
+ $ defaultShipping = 1 ;
322
+
323
+ $ customerAddress = $ this ->createMock (\Magento \Quote \Model \Quote \Address::class);
324
+ $ customerAddress ->expects ($ this ->any ())
325
+ ->method ("getVatId " )
326
+ ->willReturn ($ customerVat );
327
+
328
+ $ customerAddress ->expects ($ this ->any ())
329
+ ->method ("getCountryId " )
330
+ ->willReturn ($ customerCountryCode );
331
+
332
+ $ this ->addressRepository ->expects ($ this ->once ())
333
+ ->method ("getById " )
334
+ ->with ($ defaultShipping )
335
+ ->willReturn ($ customerAddress );
336
+
337
+ $ this ->customerMock ->expects ($ this ->atLeastOnce ())
338
+ ->method ("getDefaultShipping " )
339
+ ->willReturn ($ defaultShipping );
340
+
341
+ $ this ->vatValidatorMock ->expects ($ this ->once ())
342
+ ->method ('isEnabled ' )
343
+ ->with ($ this ->quoteAddressMock , $ this ->storeId )
344
+ ->will ($ this ->returnValue (true ));
345
+
346
+ $ this ->customerVatMock ->expects ($ this ->once ())
347
+ ->method ('isCountryInEU ' )
348
+ ->with ($ customerCountryCode )
349
+ ->willReturn (true );
350
+
351
+ $ this ->model ->execute ($ this ->observerMock );
352
+ }
353
+
317
354
public function testDispatchWithEmptyShippingAddress ()
318
355
{
319
356
$ customerCountryCode = "DE " ;
0 commit comments