TransactionTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order\Payment;
  7. /**
  8. * Tests transaction model:
  9. *
  10. * @see \Magento\Sales\Model\Order\Payment\Transaction
  11. * @magentoDataFixture Magento/Sales/_files/transactions.php
  12. */
  13. class TransactionTest extends \PHPUnit\Framework\TestCase
  14. {
  15. public function testLoadByTxnId()
  16. {
  17. $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Sales\Model\Order::class);
  18. $order->loadByIncrementId('100000001');
  19. /**
  20. * @var $repository \Magento\Sales\Model\Order\Payment\Transaction\Repository
  21. */
  22. $repository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  23. \Magento\Sales\Model\Order\Payment\Transaction\Repository::class
  24. );
  25. /**
  26. * @var $model \Magento\Sales\Model\Order\Payment\Transaction
  27. */
  28. $model = $repository->getByTransactionId(
  29. 'invalid_transaction_id',
  30. $order->getPayment()->getId(),
  31. $order->getId()
  32. );
  33. $this->assertFalse($model);
  34. $model = $repository->getByTransactionId('trx1', $order->getPayment()->getId(), $order->getId());
  35. $this->assertNotFalse($model->getId());
  36. }
  37. }