PoDataBuilderTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\Test\Unit\Gateway\Request;
  8. use Magento\AuthorizenetAcceptjs\Gateway\Request\PoDataBuilder;
  9. use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
  10. use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
  11. use Magento\Payment\Model\InfoInterface;
  12. use Magento\Sales\Model\Order\Payment;
  13. use PHPUnit\Framework\MockObject\MockObject;
  14. use PHPUnit\Framework\TestCase;
  15. class PoDataBuilderTest extends TestCase
  16. {
  17. /**
  18. * @var PoDataBuilder
  19. */
  20. private $builder;
  21. /**
  22. * @var InfoInterface|MockObject
  23. */
  24. private $paymentMock;
  25. /**
  26. * @var PaymentDataObjectInterface|MockObject
  27. */
  28. private $paymentDOMock;
  29. protected function setUp()
  30. {
  31. $this->paymentDOMock = $this->createMock(PaymentDataObjectInterface::class);
  32. $this->paymentMock = $this->createMock(Payment::class);
  33. $this->paymentDOMock->method('getPayment')
  34. ->willReturn($this->paymentMock);
  35. $this->builder = new PoDataBuilder(new SubjectReader());
  36. }
  37. public function testBuild()
  38. {
  39. $this->paymentMock->method('getPoNumber')
  40. ->willReturn('abc');
  41. $expected = [
  42. 'transactionRequest' => [
  43. 'poNumber' => 'abc'
  44. ]
  45. ];
  46. $buildSubject = [
  47. 'payment' => $this->paymentDOMock,
  48. ];
  49. $this->assertEquals($expected, $this->builder->build($buildSubject));
  50. }
  51. }