|
9 | 9 | namespace Magento\Paypal\Test\Unit\Model\Api;
|
10 | 10 |
|
11 | 11 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
|
| 12 | +use Magento\Paypal\Model\Info; |
12 | 13 |
|
13 | 14 | /**
|
14 | 15 | * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
@@ -211,6 +212,42 @@ public function testCallGetExpressCheckoutDetails()
|
211 | 212 | $this->assertEquals('testSTATE', $address->getRegion());
|
212 | 213 | }
|
213 | 214 |
|
| 215 | + /** |
| 216 | + * Tests that callDoReauthorization method is called without errors and |
| 217 | + * needed data is imported from response. |
| 218 | + */ |
| 219 | + public function testCallDoReauthorization() |
| 220 | + { |
| 221 | + $authorizationId = 555; |
| 222 | + $paymentStatus = 'Completed'; |
| 223 | + $pendingReason = 'none'; |
| 224 | + $protectionEligibility = 'Eligible'; |
| 225 | + $protectionEligibilityType = 'ItemNotReceivedEligible'; |
| 226 | + |
| 227 | + $this->curl->expects($this->once()) |
| 228 | + ->method('read') |
| 229 | + ->willReturn( |
| 230 | + "\r\n" . 'ACK=Success' |
| 231 | + . '&AUTHORIZATIONID=' . $authorizationId |
| 232 | + . '&PAYMENTSTATUS=' . $paymentStatus |
| 233 | + . '&PENDINGREASON=' . $pendingReason |
| 234 | + . '&PROTECTIONELIGIBILITY=' . $protectionEligibility |
| 235 | + . '&PROTECTIONELIGIBILITYTYPE=' . $protectionEligibilityType |
| 236 | + ); |
| 237 | + |
| 238 | + $this->model->callDoReauthorization(); |
| 239 | + |
| 240 | + $expectedImportedData = [ |
| 241 | + 'authorization_id' => $authorizationId, |
| 242 | + 'payment_status' => Info::PAYMENTSTATUS_COMPLETED, |
| 243 | + 'pending_reason' => $pendingReason, |
| 244 | + 'protection_eligibility' => $protectionEligibility |
| 245 | + ]; |
| 246 | + |
| 247 | + $this->assertNotContains($protectionEligibilityType, $this->model->getData()); |
| 248 | + $this->assertEquals($expectedImportedData, $this->model->getData()); |
| 249 | + } |
| 250 | + |
214 | 251 | public function testGetDebugReplacePrivateDataKeys()
|
215 | 252 | {
|
216 | 253 | $debugReplacePrivateDataKeys = $this->_invokeNvpProperty($this->model, '_debugReplacePrivateDataKeys');
|
|
0 commit comments