RefundSettledCommandTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\AuthorizenetAcceptjs\Gateway\Command;
  8. use Magento\AuthorizenetAcceptjs\Gateway\AbstractTest;
  9. use Magento\Payment\Gateway\Command\CommandPoolInterface;
  10. use Magento\Sales\Model\Order\Payment;
  11. class RefundSettledCommandTest extends AbstractTest
  12. {
  13. /**
  14. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/environment sandbox
  15. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/login someusername
  16. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_key somepassword
  17. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_signature_key abc
  18. * @magentoDataFixture Magento/AuthorizenetAcceptjs/Fixture/full_order_with_capture.php
  19. */
  20. public function testRefundSettledCommand()
  21. {
  22. /** @var CommandPoolInterface $commandPool */
  23. $commandPool = $this->objectManager->get('AuthorizenetAcceptjsCommandPool');
  24. $command = $commandPool->get('refund_settled');
  25. $order = $this->getOrderWithIncrementId('100000001');
  26. $payment = $order->getPayment();
  27. $paymentDO = $this->paymentFactory->create($payment);
  28. $expectedRequest = include __DIR__ . '/../../_files/expected_request/refund.php';
  29. $response = include __DIR__ . '/../../_files/response/refund.php';
  30. $this->clientMock->method('setRawData')
  31. ->with(json_encode($expectedRequest), 'application/json');
  32. $this->responseMock->method('getBody')
  33. ->willReturn(json_encode($response));
  34. $command->execute([
  35. 'payment' => $paymentDO,
  36. 'amount' => 100.00
  37. ]);
  38. /** @var Payment $payment */
  39. $this->assertTrue($payment->getIsTransactionClosed());
  40. $this->assertSame('5678', $payment->getTransactionId());
  41. }
  42. }