Skip to content

Commit 56adedd

Browse files
committed
Unit tests
1 parent 5d44525 commit 56adedd

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

app/code/Magento/Quote/Test/Unit/Observer/Frontend/Quote/Address/CollectTotalsObserverTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,43 @@ public function testDispatchWithCustomerCountryInEU()
314314
$this->model->execute($this->observerMock);
315315
}
316316

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+
317354
public function testDispatchWithEmptyShippingAddress()
318355
{
319356
$customerCountryCode = "DE";

0 commit comments

Comments
 (0)