CancelCommandTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 CancelCommandTest 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. * @dataProvider aliasesProvider
  20. */
  21. public function testCancelCommand(string $commandName)
  22. {
  23. /** @var CommandPoolInterface $commandPool */
  24. $commandPool = $this->objectManager->get('AuthorizenetAcceptjsCommandPool');
  25. $command = $commandPool->get($commandName);
  26. $order = $this->getOrderWithIncrementId('100000002');
  27. $payment = $order->getPayment();
  28. $paymentDO = $this->paymentFactory->create($payment);
  29. $expectedRequest = include __DIR__ . '/../../_files/expected_request/void.php';
  30. $response = include __DIR__ . '/../../_files/response/void.php';
  31. $this->clientMock->method('setRawData')
  32. ->with(json_encode($expectedRequest), 'application/json');
  33. $this->responseMock->method('getBody')
  34. ->willReturn(json_encode($response));
  35. $command->execute([
  36. 'payment' => $paymentDO
  37. ]);
  38. /** @var Payment $payment */
  39. $this->assertTrue($payment->getIsTransactionClosed());
  40. $this->assertTrue($payment->getShouldCloseParentTransaction());
  41. $this->assertArrayNotHasKey('real_transaction_id', $payment->getTransactionAdditionalInfo());
  42. }
  43. public function aliasesProvider()
  44. {
  45. return [
  46. ['cancel'],
  47. ['deny_payment']
  48. ];
  49. }
  50. }