10 use \PHPUnit_Framework_MockObject_MockObject as MockObject;
17 private $objectManager;
27 private $customerSessionMock;
33 $this->customerSessionMock = $this->getMockBuilder(\
Magento\Customer\Model\Session::class)
34 ->disableOriginalConstructor()
35 ->setMethods([
'setDefaultTaxBillingAddress',
'setDefaultTaxShippingAddress'])
38 $this->manager = $this->objectManager->getObject(
39 TaxAddressManager::class,
41 'customerSession' => $this->customerSessionMock,
63 list($customerDefBillAddId, $isPrimaryBilling, $isDefaultBilling) = $billingInfo;
64 list($customerDefShipAddId, $isPrimaryShipping, $isDefaultShipping) = $shippingInfo;
67 $address = $this->getMockBuilder(\
Magento\Customer\Model\Address::class)
71 'getIsPrimaryBilling',
72 'getIsDefaultBilling',
73 'getIsPrimaryShipping',
74 'getIsDefaultShipping',
79 ->disableOriginalConstructor()
82 $address->expects($this->any())->method(
'getCountryId')->willReturn(1);
83 $address->expects($this->any())->method(
'getRegion')->willReturn(
null);
84 $address->expects($this->any())->method(
'getPostcode')->willReturn(
'11111');
86 $address->expects($this->any())->method(
'getId')->willReturn($addressId);
87 $address->expects($this->any())->method(
'getIsPrimaryBilling')->willReturn($isPrimaryBilling);
88 $address->expects($this->any())->method(
'getIsDefaultBilling')->willReturn($isDefaultBilling);
89 $address->expects($this->any())->method(
'getIsPrimaryShipping')->willReturn($isPrimaryShipping);
90 $address->expects($this->any())->method(
'getIsDefaultShipping')->willReturn($isDefaultShipping);
94 ->setMethods([
'getDefaultBilling',
'getDefaultShipping'])
95 ->disableOriginalConstructor()
97 $customer->expects($this->any())->method(
'getDefaultBilling')->willReturn($customerDefBillAddId);
98 $customer->expects($this->any())->method(
'getDefaultShipping')->willReturn($customerDefShipAddId);
102 $this->customerSessionMock->expects($needSetShipping ? $this->once() : $this->never())
103 ->method(
'setDefaultTaxShippingAddress')
104 ->with([
'country_id' => 1,
'region_id' =>
null,
'postcode' => 11111]);
105 $this->customerSessionMock->expects($needSetBilling ? $this->once() : $this->never())
106 ->method(
'setDefaultTaxBillingAddress')
107 ->with([
'country_id' => 1,
'region_id' =>
null,
'postcode' => 11111]);
109 $this->manager->setDefaultAddressAfterSave(
$address);
118 [1, [1,
false,
false], [1,
false,
false],
true,
true],
119 [1, [2,
false,
false], [2,
false,
false],
false,
false],
120 [1, [2,
false,
true], [2,
false,
true],
true,
true],
121 [1, [2,
true,
false], [2,
true,
false],
true,
true],
133 $isAddressDefaultBilling,
134 $isAddressDefaultShipping
137 $address = $this->getMockBuilder(\
Magento\Customer\Api\Data\AddressInterface::class)
138 ->disableOriginalConstructor()
141 $address->expects($this->any())->method(
'getCountryId')->willReturn(1);
142 $address->expects($this->any())->method(
'getRegion')->willReturn(
null);
143 $address->expects($this->any())->method(
'getPostcode')->willReturn(
'11111');
144 $address->expects($this->any())->method(
'isDefaultShipping')->willReturn($isAddressDefaultShipping);
145 $address->expects($this->any())->method(
'isDefaultBilling')->willReturn($isAddressDefaultBilling);
147 $this->customerSessionMock->expects($isAddressDefaultShipping ? $this->once() : $this->never())
148 ->method(
'setDefaultTaxShippingAddress')
149 ->with([
'country_id' => 1,
'region_id' =>
null,
'postcode' => 11111]);
150 $this->customerSessionMock->expects($isAddressDefaultBilling ? $this->once() : $this->never())
151 ->method(
'setDefaultTaxBillingAddress')
152 ->with([
'country_id' => 1,
'region_id' =>
null,
'postcode' => 11111]);
154 $this->manager->setDefaultAddressAfterLogIn([
$address]);
setAddressCustomerSessionLogInDataProvider()
setAddressCustomerSessionAddressSaveDataProvider()
testSetDefaultAddressAfterLogIn( $isAddressDefaultBilling, $isAddressDefaultShipping)
testSetDefaultAddressAfterSave( $addressId, $billingInfo, $shippingInfo, $needSetShipping, $needSetBilling)