|
5 | 5 | */
|
6 | 6 | namespace Magento\Paypal\Test\Unit\Model\Hostedpro;
|
7 | 7 |
|
| 8 | +use Magento\Framework\DataObject; |
| 9 | +use Magento\Sales\Model\Order; |
| 10 | +use Magento\Sales\Model\Order\Payment; |
| 11 | + |
8 | 12 | class RequestTest extends \PHPUnit_Framework_TestCase
|
9 | 13 | {
|
10 | 14 | /**
|
@@ -44,75 +48,82 @@ protected function setUp()
|
44 | 48 | }
|
45 | 49 |
|
46 | 50 | /**
|
| 51 | + * @param $billing |
| 52 | + * @param $shipping |
| 53 | + * @param $billingState |
| 54 | + * @param $state |
| 55 | + * @param $countryId |
47 | 56 | * @dataProvider addressesDataProvider
|
48 | 57 | */
|
49 |
| - public function testSetOrderAddresses($billing, $shipping, $billingState, $state) |
| 58 | + public function testSetOrderAddresses($billing, $shipping, $billingState, $state, $countryId) |
50 | 59 | {
|
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()) |
60 | 69 | ->method('getPayment')
|
61 | 70 | ->will($this->returnValue($payment));
|
62 |
| - $order->expects($this->any()) |
| 71 | + $order->expects(static::any()) |
63 | 72 | ->method('getBillingAddress')
|
64 | 73 | ->will($this->returnValue($billing));
|
65 |
| - $order->expects($this->any()) |
| 74 | + $order->expects(static::any()) |
66 | 75 | ->method('getShippingAddress')
|
67 | 76 | ->will($this->returnValue($shipping));
|
68 | 77 | $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')); |
71 | 82 | }
|
72 | 83 |
|
73 | 84 | /**
|
74 | 85 | * @return array
|
75 | 86 | */
|
76 | 87 | public function addressesDataProvider()
|
77 | 88 | {
|
78 |
| - $billing = new \Magento\Framework\DataObject([ |
| 89 | + $billing = new DataObject([ |
79 | 90 | 'firstname' => 'Firstname',
|
80 | 91 | 'lastname' => 'Lastname',
|
81 | 92 | 'city' => 'City',
|
82 | 93 | 'region_code' => 'CA',
|
83 | 94 | 'postcode' => '12346',
|
84 |
| - 'country' => 'United States', |
85 |
| - 'Street' => '1 Ln Ave', |
| 95 | + 'country_id' => 'US', |
| 96 | + 'street' => '1 Ln Ave', |
86 | 97 | ]);
|
87 |
| - $shipping = new \Magento\Framework\DataObject([ |
| 98 | + $shipping = new DataObject([ |
88 | 99 | 'firstname' => 'ShipFirstname',
|
89 | 100 | 'lastname' => 'ShipLastname',
|
90 | 101 | 'city' => 'ShipCity',
|
91 | 102 | 'region' => 'olala',
|
92 | 103 | 'postcode' => '12346',
|
93 |
| - 'country' => 'United States', |
94 |
| - 'Street' => '1 Ln Ave', |
| 104 | + 'country_id' => 'US', |
| 105 | + 'street' => '1 Ln Ave', |
95 | 106 | ]);
|
96 |
| - $billing2 = new \Magento\Framework\DataObject([ |
| 107 | + $billing2 = new DataObject([ |
97 | 108 | 'firstname' => 'Firstname',
|
98 | 109 | 'lastname' => 'Lastname',
|
99 |
| - 'city' => 'City', |
100 |
| - 'region_code' => 'muuuu', |
| 110 | + 'city' => 'Culver City', |
| 111 | + 'region_code' => 'CA', |
101 | 112 | 'postcode' => '12346',
|
102 |
| - 'country' => 'United States', |
103 |
| - 'Street' => '1 Ln Ave', |
| 113 | + 'country_id' => 'US', |
| 114 | + 'street' => '1 Ln Ave', |
104 | 115 | ]);
|
105 |
| - $shipping2 = new \Magento\Framework\DataObject([ |
| 116 | + $shipping2 = new DataObject([ |
106 | 117 | 'firstname' => 'ShipFirstname',
|
107 | 118 | 'lastname' => 'ShipLastname',
|
108 | 119 | 'city' => 'ShipCity',
|
109 | 120 | 'postcode' => '12346',
|
110 |
| - 'country' => 'United States', |
111 |
| - 'Street' => '1 Ln Ave', |
| 121 | + 'country_id' => 'US', |
| 122 | + 'street' => '1 Ln Ave', |
112 | 123 | ]);
|
113 | 124 | return [
|
114 |
| - [$billing, $shipping, 'CA', 'olala'], |
115 |
| - [$billing2, $shipping2, 'muuuu', 'ShipCity'] |
| 125 | + [$billing, $shipping, 'CA', 'olala', 'US'], |
| 126 | + [$billing2, $shipping2, 'CA', 'ShipCity', 'US'] |
116 | 127 | ];
|
117 | 128 | }
|
118 | 129 |
|
|
0 commit comments