PaymentTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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\Block;
  8. use Magento\AuthorizenetAcceptjs\Block\Payment;
  9. use Magento\AuthorizenetAcceptjs\Model\Ui\ConfigProvider;
  10. use Magento\Framework\Serialize\Serializer\Json;
  11. use Magento\Framework\View\Element\Template\Context;
  12. use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
  13. use PHPUnit\Framework\MockObject\MockObject;
  14. use PHPUnit\Framework\TestCase;
  15. class PaymentTest extends TestCase
  16. {
  17. /**
  18. * @var ConfigProvider|MockObject|InvocationMocker
  19. */
  20. private $configMock;
  21. /**
  22. * @var Payment
  23. */
  24. private $block;
  25. protected function setUp()
  26. {
  27. $contextMock = $this->createMock(Context::class);
  28. $this->configMock = $this->createMock(ConfigProvider::class);
  29. $this->block = new Payment($contextMock, $this->configMock, new Json());
  30. }
  31. public function testConfigIsCreated()
  32. {
  33. $this->configMock->method('getConfig')
  34. ->willReturn([
  35. 'payment' => [
  36. 'authorizenet_acceptjs' => [
  37. 'foo' => 'bar'
  38. ]
  39. ]
  40. ]);
  41. $result = $this->block->getPaymentConfig();
  42. $expected = '{"foo":"bar","code":"authorizenet_acceptjs"}';
  43. $this->assertEquals($expected, $result);
  44. }
  45. }