@@ -303,17 +303,15 @@ private function executeTestFlow($flatRateAmount, $tableRateAmount)
303
303
*/
304
304
public function testEstimateByAddressWithInclExclTaxAndVATGroup ()
305
305
{
306
- $ this ->mockCustomerVat ();
307
-
308
- /** @var CustomerRepositoryInterface $customerRepository */
309
- $ customerRepository = $ this ->objectManager ->get (CustomerRepositoryInterface::class);
310
- $ customer = $ customerRepository ->get ('customer@example.com ' );
311
-
312
306
/** @var GroupInterface $customerGroup */
313
307
$ customerGroup = $ this ->findCustomerGroupByCode ('custom_group ' );
308
+ $ this ->mockCustomerVat ((int )$ customerGroup ->getId ());
309
+
314
310
$ customerGroup ->setTaxClassId ($ this ->getTaxClass ('CustomerTaxClass ' )->getClassId ());
315
311
$ this ->groupRepository ->save ($ customerGroup );
316
-
312
+ /** @var CustomerRepositoryInterface $customerRepository */
313
+ $ customerRepository = $ this ->objectManager ->get (CustomerRepositoryInterface::class);
314
+ $ customer = $ customerRepository ->get ('customer@example.com ' );
317
315
$ customer ->setGroupId ($ customerGroup ->getId ());
318
316
$ customer ->setTaxvat ('12 ' );
319
317
$ customerRepository ->save ($ customer );
@@ -332,8 +330,10 @@ public function testEstimateByAddressWithInclExclTaxAndVATGroup()
332
330
333
331
/**
334
332
* Create a test double fot customer vat class
333
+ *
334
+ * @param int $customerGroupId
335
335
*/
336
- private function mockCustomerVat (): void
336
+ private function mockCustomerVat (int $ customerGroupId ): void
337
337
{
338
338
$ gatewayResponse = new DataObject ([
339
339
'is_valid ' => false ,
@@ -356,14 +356,12 @@ private function mockCustomerVat(): void
356
356
$ customerVat ->method ('isCountryInEU ' )->willReturn (true );
357
357
$ customerVat ->method ('getMerchantCountryCode ' )->willReturn ('GB ' );
358
358
$ customerVat ->method ('getMerchantVatNumber ' )->willReturn ('11111 ' );
359
- $ customerVat ->method ('getCustomerGroupIdBasedOnVatNumber ' )->willReturn (' 4 ' );
359
+ $ customerVat ->method ('getCustomerGroupIdBasedOnVatNumber ' )->willReturn ($ customerGroupId );
360
360
$ this ->objectManager ->removeSharedInstance (Vat::class);
361
361
$ this ->objectManager ->addSharedInstance ($ customerVat , Vat::class);
362
362
363
363
// Remove instances where the customer vat object is cached
364
364
$ this ->objectManager ->removeSharedInstance (CollectTotalsObserver::class);
365
- $ this ->objectManager ->removeSharedInstance (AfterAddressSaveObserver::class);
366
- $ this ->objectManager ->removeSharedInstance (VatValidator::class);
367
365
}
368
366
369
367
/**
0 commit comments