AuthenticationDataBuilderTest.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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\Config;
  9. use Magento\AuthorizenetAcceptjs\Gateway\Request\AuthenticationDataBuilder;
  10. use Magento\AuthorizenetAcceptjs\Gateway\SubjectReader;
  11. use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
  12. use Magento\Sales\Model\Order\Payment;
  13. use PHPUnit\Framework\MockObject\MockObject;
  14. use PHPUnit\Framework\TestCase;
  15. class AuthenticationDataBuilderTest extends TestCase
  16. {
  17. /**
  18. * @var AuthenticationDataBuilder
  19. */
  20. private $builder;
  21. /**
  22. * @var Payment|MockObject
  23. */
  24. private $paymentMock;
  25. /**
  26. * @var Payment|MockObject
  27. */
  28. private $paymentDOMock;
  29. /**
  30. * @var SubjectReader|MockObject
  31. */
  32. private $subjectReaderMock;
  33. /**
  34. * @var Config|MockObject
  35. */
  36. private $configMock;
  37. protected function setUp()
  38. {
  39. $this->configMock = $this->createMock(Config::class);
  40. $this->paymentDOMock = $this->createMock(PaymentDataObjectInterface::class);
  41. $this->paymentMock = $this->createMock(Payment::class);
  42. /** @var MockObject|SubjectReader subjectReaderMock */
  43. $this->subjectReaderMock = $this->createMock(SubjectReader::class);
  44. $this->builder = new AuthenticationDataBuilder($this->subjectReaderMock, $this->configMock);
  45. }
  46. public function testBuild()
  47. {
  48. $this->configMock->method('getLoginId')
  49. ->willReturn('myloginid');
  50. $this->configMock->method('getTransactionKey')
  51. ->willReturn('mytransactionkey');
  52. $expected = [
  53. 'merchantAuthentication' => [
  54. 'name' => 'myloginid',
  55. 'transactionKey' => 'mytransactionkey'
  56. ]
  57. ];
  58. $buildSubject = [];
  59. $this->subjectReaderMock->method('readStoreId')
  60. ->with($buildSubject)
  61. ->willReturn(123);
  62. $this->assertEquals($expected, $this->builder->build($buildSubject));
  63. }
  64. }