SettleCommandTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 SettleCommandTest 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/order_auth_only.php
  19. */
  20. public function testRefundSettledCommand()
  21. {
  22. /** @var CommandPoolInterface $commandPool */
  23. $commandPool = $this->objectManager->get('AuthorizenetAcceptjsCommandPool');
  24. $command = $commandPool->get('settle');
  25. $order = $this->getOrderWithIncrementId('100000002');
  26. $payment = $order->getPayment();
  27. $paymentDO = $this->paymentFactory->create($payment);
  28. $expectedRequest = include __DIR__ . '/../../_files/expected_request/settle.php';
  29. $response = include __DIR__ . '/../../_files/response/settle.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->getShouldCloseParentTransaction());
  40. }
  41. }