ConfigProviderTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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\Model\Ui;
  8. use Magento\AuthorizenetAcceptjs\Gateway\Config;
  9. use Magento\AuthorizenetAcceptjs\Model\Ui\ConfigProvider;
  10. use Magento\Quote\Api\Data\CartInterface;
  11. use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
  12. use PHPUnit\Framework\MockObject\MockObject;
  13. use PHPUnit\Framework\TestCase;
  14. class ConfigProviderTest extends TestCase
  15. {
  16. /**
  17. * @var CartInterface|MockObject|InvocationMocker
  18. */
  19. private $cart;
  20. /**
  21. * @var Config|MockObject|InvocationMocker
  22. */
  23. private $config;
  24. /**
  25. * @var ConfigProvider
  26. */
  27. private $provider;
  28. protected function setUp()
  29. {
  30. $this->cart = $this->createMock(CartInterface::class);
  31. $this->config = $this->createMock(Config::class);
  32. $this->provider = new ConfigProvider($this->config, $this->cart);
  33. }
  34. public function testProviderRetrievesValues()
  35. {
  36. $this->cart->method('getStoreId')
  37. ->willReturn('123');
  38. $this->config->method('getClientKey')
  39. ->with('123')
  40. ->willReturn('foo');
  41. $this->config->method('getLoginId')
  42. ->with('123')
  43. ->willReturn('bar');
  44. $this->config->method('getEnvironment')
  45. ->with('123')
  46. ->willReturn('baz');
  47. $this->config->method('isCvvEnabled')
  48. ->with('123')
  49. ->willReturn(false);
  50. $expected = [
  51. 'payment' => [
  52. Config::METHOD => [
  53. 'clientKey' => 'foo',
  54. 'apiLoginID' => 'bar',
  55. 'environment' => 'baz',
  56. 'useCvv' => false,
  57. ]
  58. ]
  59. ];
  60. $this->assertEquals($expected, $this->provider->getConfig());
  61. }
  62. }