@@ -78,6 +78,11 @@ class TransparentTest extends TestCase
78
78
*/
79
79
private $ order ;
80
80
81
+ /**
82
+ * @var OrderPaymentExtensionInterface|MockObject
83
+ */
84
+ private $ paymentExtensionAttributes ;
85
+
81
86
protected function setUp (): void
82
87
{
83
88
$ this ->initPayment ();
@@ -97,6 +102,55 @@ protected function setUp(): void
97
102
);
98
103
}
99
104
105
+ /**
106
+ * Check correct parent transaction ID for Payflow delayed capture.
107
+ *
108
+ * @dataProvider captureCorrectIdDataProvider
109
+ * @param string $parentTransactionId
110
+ * @throws InvalidTransitionException
111
+ * @throws LocalizedException
112
+ */
113
+ public function testCaptureCorrectId (string $ parentTransactionId )
114
+ {
115
+ if (empty ($ parentTransactionId )) {
116
+ $ setParentTransactionIdCalls = 1 ;
117
+ $ setAdditionalInformationCalls = 1 ;
118
+ $ getGatewayTokenCalls = 2 ;
119
+ } else {
120
+ $ setParentTransactionIdCalls = 0 ;
121
+ $ setAdditionalInformationCalls = 0 ;
122
+ $ getGatewayTokenCalls = 0 ;
123
+ }
124
+
125
+ $ gatewayToken = 'gateway_token ' ;
126
+ $ this ->payment ->expects ($ this ->once ())->method ('getParentTransactionId ' )->willReturn ($ parentTransactionId );
127
+ $ this ->payment ->expects ($ this ->exactly ($ setParentTransactionIdCalls ))->method ('setParentTransactionId ' );
128
+ $ this ->payment ->expects ($ this ->exactly ($ setAdditionalInformationCalls ))->method ('setAdditionalInformation ' )->with (Payflowpro::PNREF , $ gatewayToken );
129
+ $ this ->payment ->expects ($ this ->exactly (4 ))->method ('getAdditionalInformation ' )->withConsecutive (
130
+ ['result_code ' ],
131
+ [Payflowpro::PNREF ],
132
+ [Payflowpro::PNREF ],
133
+ [Payflowpro::PNREF ],
134
+ )->willReturn (0 , '' , Payflowpro::PNREF , Payflowpro::PNREF );
135
+ $ this ->paymentExtensionAttributes ->expects ($ this ->once ())->method ('getVaultPaymentToken ' )->willReturn ($ this ->paymentToken );
136
+ $ this ->paymentToken ->expects ($ this ->exactly ($ getGatewayTokenCalls ))->method ('getGatewayToken ' )->willReturn ($ gatewayToken );
137
+
138
+ $ this ->subject ->capture ($ this ->payment , 100 );
139
+ }
140
+
141
+ /**
142
+ * Data provider for testCaptureCorrectId.
143
+ *
144
+ * @return array
145
+ */
146
+ public function captureCorrectIdDataProvider (): array
147
+ {
148
+ return [
149
+ 'No Transaction ID ' => ['' ],
150
+ 'With Transaction ID ' => ['1 ' ],
151
+ ];
152
+ }
153
+
100
154
/**
101
155
* Asserts that authorize request to Payflow gateway is valid.
102
156
*
@@ -295,7 +349,7 @@ private function initPayment()
295
349
$ this ->order = $ this ->getMockBuilder (Order::class)
296
350
->disableOriginalConstructor ()
297
351
->getMock ();
298
- $ paymentExtensionAttributes = $ this ->getMockBuilder (OrderPaymentExtensionInterface::class)
352
+ $ this -> paymentExtensionAttributes = $ this ->getMockBuilder (OrderPaymentExtensionInterface::class)
299
353
->setMethods (
300
354
['setVaultPaymentToken ' , 'getVaultPaymentToken ' , 'setNotificationMessage ' , 'getNotificationMessage ' ]
301
355
)
@@ -305,7 +359,7 @@ private function initPayment()
305
359
$ this ->payment ->method ('setIsTransactionClosed ' )->willReturnSelf ();
306
360
$ this ->payment ->method ('getCcExpYear ' )->willReturn ('2019 ' );
307
361
$ this ->payment ->method ('getCcExpMonth ' )->willReturn ('05 ' );
308
- $ this ->payment ->method ('getExtensionAttributes ' )->willReturn ($ paymentExtensionAttributes );
362
+ $ this ->payment ->method ('getExtensionAttributes ' )->willReturn ($ this -> paymentExtensionAttributes );
309
363
310
364
return $ this ->payment ;
311
365
}
0 commit comments