Skip to content

Commit 0f7b395

Browse files
author
Robert He
committed
Merge branch 'FearlessKiwis-MAGETWO-43189-fpt-based-on-billing-addr' of https://github.corp.ebay.com/magento-fearless-kiwis/magento2ce into develop
2 parents 02a80bd + 851f6d0 commit 0f7b395

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

app/code/Magento/Weee/Model/Tax.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,12 @@ public function getProductWeeeAttributes(
226226
/** @var \Magento\Tax\Model\Calculation $calculator */
227227
$calculator = $this->_calculationFactory->create();
228228

229+
$customerId = $this->_customerSession->getCustomerId();
229230
if ($shipping && $shipping->getCountryId()) {
230231
$customerTaxClass = $shipping->getQuote()->getCustomerTaxClassId();
231232
} else {
232233
// if customer logged use it default shipping and billing address
233-
if ($customerId = $this->_customerSession->getCustomerId()) {
234+
if ($customerId) {
234235
$shipping = $this->accountManagement->getDefaultShippingAddress($customerId);
235236
$billing = $this->accountManagement->getDefaultBillingAddress($customerId);
236237
$customerTaxClass = null;
@@ -251,7 +252,8 @@ public function getProductWeeeAttributes(
251252
$shipping,
252253
$billing,
253254
$customerTaxClass,
254-
$store
255+
$store,
256+
$customerId
255257
);
256258
$defaultRateRequest = $calculator->getDefaultRateRequest($store);
257259

app/code/Magento/Weee/Test/Unit/Model/TaxTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,17 @@ protected function setUp()
110110
$this->calculationFactory = $this->getMock($className, ['create'], [], '', false);
111111

112112
$className = '\Magento\Customer\Model\Session';
113-
$this->customerSession = $this->getMock($className, [], [], '', false);
113+
$this->customerSession = $this->getMock(
114+
$className,
115+
['getCustomerId', 'getDefaultTaxShippingAddress', 'getDefaultTaxBillingAddress', 'getCustomerTaxClassId'],
116+
[],
117+
'',
118+
false
119+
);
120+
$this->customerSession->expects($this->any())->method('getCustomerId')->willReturn(null);
121+
$this->customerSession->expects($this->any())->method('getDefaultTaxShippingAddress')->willReturn(null);
122+
$this->customerSession->expects($this->any())->method('getDefaultTaxBillingAddress')->willReturn(null);
123+
$this->customerSession->expects($this->any())->method('getCustomerTaxClassId')->willReturn(null);
114124

115125
$className = '\Magento\Customer\Api\AccountManagementInterface';
116126
$this->accountManagement = $this->getMock($className, [], [], '', false);
@@ -165,11 +175,9 @@ public function testGetProductWeeeAttributes()
165175
$calculation->expects($this->once())
166176
->method('getRateRequest')
167177
->willReturn($obj);
168-
169178
$calculation->expects($this->once())
170179
->method('getDefaultRateRequest')
171180
->willReturn($obj);
172-
173181
$calculation->expects($this->any())
174182
->method('getRate')
175183
->willReturn('10');
@@ -178,10 +186,6 @@ public function testGetProductWeeeAttributes()
178186
->method('getAttributeCodesByFrontendType')
179187
->willReturn(['0'=>'fpt']);
180188

181-
$website->expects($this->any())
182-
->method('getId')
183-
->willReturn(1);
184-
185189
$store->expects($this->any())
186190
->method('getId')
187191
->willReturn(1);
@@ -190,6 +194,9 @@ public function testGetProductWeeeAttributes()
190194
->method('getId')
191195
->willReturn(1);
192196

197+
$website->expects($this->any())
198+
->method('getId')
199+
->willReturn(1);
193200
$website->expects($this->any())
194201
->method('getDefaultGroup')
195202
->willReturn($group);

0 commit comments

Comments
 (0)