@@ -125,15 +125,21 @@ public function testCaptureCorrectId(string $parentTransactionId)
125125 $ gatewayToken = 'gateway_token ' ;
126126 $ this ->payment ->expects ($ this ->once ())->method ('getParentTransactionId ' )->willReturn ($ parentTransactionId );
127127 $ this ->payment ->expects ($ this ->exactly ($ setParentTransactionIdCalls ))->method ('setParentTransactionId ' );
128- $ this ->payment ->expects ($ this ->exactly ($ setAdditionalInformationCalls ))->method ('setAdditionalInformation ' )->with (Payflowpro::PNREF , $ gatewayToken );
128+ $ this ->payment ->expects ($ this ->exactly ($ setAdditionalInformationCalls ))
129+ ->method ('setAdditionalInformation ' )
130+ ->with (Payflowpro::PNREF , $ gatewayToken );
129131 $ this ->payment ->expects ($ this ->exactly (4 ))->method ('getAdditionalInformation ' )->withConsecutive (
130132 ['result_code ' ],
131133 [Payflowpro::PNREF ],
132134 [Payflowpro::PNREF ],
133135 [Payflowpro::PNREF ],
134136 )->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+ $ this ->paymentExtensionAttributes ->expects ($ this ->once ())
138+ ->method ('getVaultPaymentToken ' )
139+ ->willReturn ($ this ->paymentToken );
140+ $ this ->paymentToken ->expects ($ this ->exactly ($ getGatewayTokenCalls ))
141+ ->method ('getGatewayToken ' )
142+ ->willReturn ($ gatewayToken );
137143
138144 $ this ->subject ->capture ($ this ->payment , 100 );
139145 }
@@ -235,7 +241,7 @@ private function getPaymentConfigInterfaceFactory()
235241 ->disableOriginalConstructor ()
236242 ->getMock ();
237243 $ this ->paymentConfig = $ this ->getMockBuilder (PaymentConfigInterface::class)
238- ->setMethods (['setStoreId ' , 'setMethodInstance ' , 'setMethod ' , 'getBuildNotationCode ' ])
244+ ->addMethods (['setStoreId ' , 'setMethodInstance ' , 'setMethod ' , 'getBuildNotationCode ' , ' getPaymentAction ' ])
239245 ->getMockForAbstractClass ();
240246
241247 $ paymentConfigInterfaceFactory ->method ('create ' )->willReturn ($ this ->paymentConfig );
@@ -345,6 +351,23 @@ private function initPayment()
345351 {
346352 $ this ->payment = $ this ->getMockBuilder (Payment::class)
347353 ->disableOriginalConstructor ()
354+ ->addMethods (['getIsTransactionApproved ' ])
355+ ->onlyMethods (
356+ [
357+ 'setTransactionId ' ,
358+ 'setIsTransactionClosed ' ,
359+ 'getCcExpYear ' ,
360+ 'getCcExpMonth ' ,
361+ 'getExtensionAttributes ' ,
362+ 'getOrder ' ,
363+ 'authorize ' ,
364+ 'canFetchTransactionInfo ' ,
365+ 'getParentTransactionId ' ,
366+ 'setParentTransactionId ' ,
367+ 'setAdditionalInformation ' ,
368+ 'getAdditionalInformation '
369+ ]
370+ )
348371 ->getMock ();
349372 $ this ->order = $ this ->getMockBuilder (Order::class)
350373 ->disableOriginalConstructor ()
@@ -360,7 +383,16 @@ private function initPayment()
360383 $ this ->payment ->method ('getCcExpYear ' )->willReturn ('2019 ' );
361384 $ this ->payment ->method ('getCcExpMonth ' )->willReturn ('05 ' );
362385 $ this ->payment ->method ('getExtensionAttributes ' )->willReturn ($ this ->paymentExtensionAttributes );
386+ $ this ->payment ->method ('getIsTransactionApproved ' )->willReturn (true );
363387
364388 return $ this ->payment ;
365389 }
390+
391+ public function testFetchTransactionInfo ()
392+ {
393+ $ this ->payment ->method ('canFetchTransactionInfo ' )->willReturn (false );
394+ $ this ->paymentConfig ->method ('getPaymentAction ' )->willReturn ('authorize ' );
395+ $ this ->payment ->expects ($ this ->never ())->method ('authorize ' );
396+ $ this ->subject ->fetchTransactionInfo ($ this ->payment , '123 ' );
397+ }
366398}
0 commit comments