TransactionDetailsCommandTest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. class TransactionDetailsCommandTest extends AbstractTest
  11. {
  12. /**
  13. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/environment sandbox
  14. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/login someusername
  15. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_key somepassword
  16. * @magentoConfigFixture default_store payment/authorizenet_acceptjs/trans_signature_key abc
  17. * @magentoDataFixture Magento/AuthorizenetAcceptjs/Fixture/order_captured.php
  18. */
  19. public function testTransactionDetails()
  20. {
  21. /** @var CommandPoolInterface $commandPool */
  22. $commandPool = $this->objectManager->get('AuthorizenetAcceptjsCommandPool');
  23. $command = $commandPool->get('get_transaction_details');
  24. $order = $this->getOrderWithIncrementId('100000002');
  25. $payment = $order->getPayment();
  26. $paymentDO = $this->paymentFactory->create($payment);
  27. $expectedRequest = include __DIR__ . '/../../_files/expected_request/transaction_details.php';
  28. $response = include __DIR__ . '/../../_files/response/transaction_details_settled_capture.php';
  29. $this->clientMock->method('setRawData')
  30. ->with(json_encode($expectedRequest), 'application/json');
  31. $this->responseMock->method('getBody')
  32. ->willReturn(json_encode($response));
  33. $result = $command->execute([
  34. 'payment' => $paymentDO
  35. ]);
  36. $resultData = $result->get();
  37. $this->assertEquals($response, $resultData);
  38. }
  39. }