Skip to content

Commit c44bb50

Browse files
author
Ievgen Sentiabov
committed
MAGETWO-45261: Shipping and billing country are missing from the information transmitted to paypal
- Changed getter for address magic option
1 parent d66e664 commit c44bb50

File tree

2 files changed

+43
-32
lines changed

2 files changed

+43
-32
lines changed

app/code/Magento/Paypal/Model/Hostedpro/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ protected function _getShippingAddress(\Magento\Framework\DataObject $address)
273273
'city' => $address->getCity(),
274274
'state' => $region ? $region : $address->getCity(),
275275
'zip' => $address->getPostcode(),
276-
'country' => $address->getCountry(),
276+
'country' => $address->getCountryId(),
277277
];
278278

279279
// convert streets to tow lines format
@@ -301,7 +301,7 @@ protected function _getBillingAddress(\Magento\Framework\DataObject $address)
301301
'billing_city' => $address->getCity(),
302302
'billing_state' => $region ? $region : $address->getCity(),
303303
'billing_zip' => $address->getPostcode(),
304-
'billing_country' => $address->getCountry(),
304+
'billing_country' => $address->getCountryId(),
305305
];
306306

307307
// convert streets to tow lines format

app/code/Magento/Paypal/Test/Unit/Model/Hostedpro/RequestTest.php

Lines changed: 41 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
*/
66
namespace Magento\Paypal\Test\Unit\Model\Hostedpro;
77

8+
use Magento\Framework\DataObject;
9+
use Magento\Sales\Model\Order;
10+
use Magento\Sales\Model\Order\Payment;
11+
812
class RequestTest extends \PHPUnit_Framework_TestCase
913
{
1014
/**
@@ -44,75 +48,82 @@ protected function setUp()
4448
}
4549

4650
/**
51+
* @param $billing
52+
* @param $shipping
53+
* @param $billingState
54+
* @param $state
55+
* @param $countryId
4756
* @dataProvider addressesDataProvider
4857
*/
49-
public function testSetOrderAddresses($billing, $shipping, $billingState, $state)
58+
public function testSetOrderAddresses($billing, $shipping, $billingState, $state, $countryId)
5059
{
51-
$payment = $this->getMock('Magento\Sales\Model\Order\Payment', ['__wakeup'], [], '', false);
52-
$order = $this->getMock(
53-
'Magento\Sales\Model\Order',
54-
['getPayment', '__wakeup', 'getBillingAddress', 'getShippingAddress'],
55-
[],
56-
'',
57-
false
58-
);
59-
$order->expects($this->any())
60+
$payment = $this->getMockBuilder(Payment::class)
61+
->disableOriginalConstructor()
62+
->setMethods(['__wakeup'])
63+
->getMock();
64+
$order = $this->getMockBuilder(Order::class)
65+
->disableOriginalConstructor()
66+
->setMethods(['getPayment', '__wakeup', 'getBillingAddress', 'getShippingAddress'])
67+
->getMock();
68+
$order->expects(static::any())
6069
->method('getPayment')
6170
->will($this->returnValue($payment));
62-
$order->expects($this->any())
71+
$order->expects(static::any())
6372
->method('getBillingAddress')
6473
->will($this->returnValue($billing));
65-
$order->expects($this->any())
74+
$order->expects(static::any())
6675
->method('getShippingAddress')
6776
->will($this->returnValue($shipping));
6877
$this->_model->setOrder($order);
69-
$this->assertEquals($billingState, $this->_model->getData('billing_state'));
70-
$this->assertEquals($state, $this->_model->getData('state'));
78+
static::assertEquals($billingState, $this->_model->getData('billing_state'));
79+
static::assertEquals($state, $this->_model->getData('state'));
80+
static::assertEquals($countryId, $this->_model->getData('billing_country'));
81+
static::assertEquals($countryId, $this->_model->getData('country'));
7182
}
7283

7384
/**
7485
* @return array
7586
*/
7687
public function addressesDataProvider()
7788
{
78-
$billing = new \Magento\Framework\DataObject([
89+
$billing = new DataObject([
7990
'firstname' => 'Firstname',
8091
'lastname' => 'Lastname',
8192
'city' => 'City',
8293
'region_code' => 'CA',
8394
'postcode' => '12346',
84-
'country' => 'United States',
85-
'Street' => '1 Ln Ave',
95+
'country_id' => 'US',
96+
'street' => '1 Ln Ave',
8697
]);
87-
$shipping = new \Magento\Framework\DataObject([
98+
$shipping = new DataObject([
8899
'firstname' => 'ShipFirstname',
89100
'lastname' => 'ShipLastname',
90101
'city' => 'ShipCity',
91102
'region' => 'olala',
92103
'postcode' => '12346',
93-
'country' => 'United States',
94-
'Street' => '1 Ln Ave',
104+
'country_id' => 'US',
105+
'street' => '1 Ln Ave',
95106
]);
96-
$billing2 = new \Magento\Framework\DataObject([
107+
$billing2 = new DataObject([
97108
'firstname' => 'Firstname',
98109
'lastname' => 'Lastname',
99-
'city' => 'City',
100-
'region_code' => 'muuuu',
110+
'city' => 'Culver City',
111+
'region_code' => 'CA',
101112
'postcode' => '12346',
102-
'country' => 'United States',
103-
'Street' => '1 Ln Ave',
113+
'country_id' => 'US',
114+
'street' => '1 Ln Ave',
104115
]);
105-
$shipping2 = new \Magento\Framework\DataObject([
116+
$shipping2 = new DataObject([
106117
'firstname' => 'ShipFirstname',
107118
'lastname' => 'ShipLastname',
108119
'city' => 'ShipCity',
109120
'postcode' => '12346',
110-
'country' => 'United States',
111-
'Street' => '1 Ln Ave',
121+
'country_id' => 'US',
122+
'street' => '1 Ln Ave',
112123
]);
113124
return [
114-
[$billing, $shipping, 'CA', 'olala'],
115-
[$billing2, $shipping2, 'muuuu', 'ShipCity']
125+
[$billing, $shipping, 'CA', 'olala', 'US'],
126+
[$billing2, $shipping2, 'CA', 'ShipCity', 'US']
116127
];
117128
}
118129

0 commit comments

Comments
 (0)