$tokenFactory =
$this->
createMock(JWTFactoryV2::
class);
$tokenFactory->
expects(static::
once())->
method('parseToken'
)->
with('paymentToken'
)->
willReturn(new TokenStruct('id', 'token', 'paymentMethodId',
$transactionId, 'finishUrl', \PHP_INT_MAX
));
$tokenFactory->
expects(static::
once())->
method('invalidateToken'
)->
with('token'
);
$eventDispatcher =
$this->
createMock(EventDispatcherInterface::
class);
$eventDispatcher->
expects(static::
once())->
method('dispatch'
)->
with(static::
isInstanceOf(FinalizePaymentOrderTransactionCriteriaEvent::
class));
$transactionRepository =
$this->
createMock(EntityRepository::
class);
$transactionRepository->
expects(static::
once())->
method('search'
)->
with(static::
callback(function DCriteria
$criteria) use ($transactionId) { static::
assertEquals($transactionId,
$criteria->
getIds()[0
]);
static::
assertSame('payment-service::load-transaction',
$criteria->
getTitle());
static::
assertTrue($criteria->
hasAssociation('order'
));
static::
assertTrue($criteria->
hasAssociation('paymentMethod'
));
return true;
}))->
willReturn(new EntitySearchResult('order_transaction', 1,
new OrderTransactionCollection([$transaction]), null,
new Criteria(),
$context->
getContext()));
$struct =
new AsyncPaymentTransactionStruct($transaction,
$order, ''
);
$paymentStructFactory =
$this->
createMock(AbstractPaymentTransactionStructFactory::
class);
$paymentStructFactory->
expects(static::
once())->
method('async'
)->
willReturn($struct);
$paymentHandler =
$this->
createMock(AsynchronousPaymentHandlerInterface::
class);
$paymentHandler->
expects(static::
once())->
method('finalize'
)->
with($struct,
$request,
$context);