ConfigProviderTest.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Braintree\Test\Unit\Model\Ui\PayPal;
  7. use Magento\Braintree\Gateway\Config\PayPal\Config;
  8. use Magento\Braintree\Model\Ui\PayPal\ConfigProvider;
  9. use Magento\Framework\Locale\ResolverInterface;
  10. use PHPUnit_Framework_MockObject_MockObject as MockObject;
  11. /**
  12. * Class ConfigProviderTest
  13. *
  14. * Test for class \Magento\Braintree\Model\Ui\PayPal\ConfigProvider
  15. */
  16. class ConfigProviderTest extends \PHPUnit\Framework\TestCase
  17. {
  18. /**
  19. * @var Config|MockObject
  20. */
  21. private $config;
  22. /**
  23. * @var ResolverInterface|MockObject
  24. */
  25. private $localeResolver;
  26. /**
  27. * @var ConfigProvider
  28. */
  29. private $configProvider;
  30. protected function setUp()
  31. {
  32. $this->config = $this->getMockBuilder(Config::class)
  33. ->disableOriginalConstructor()
  34. ->getMock();
  35. $this->localeResolver = $this->getMockForAbstractClass(ResolverInterface::class);
  36. $this->configProvider = new ConfigProvider(
  37. $this->config,
  38. $this->localeResolver
  39. );
  40. }
  41. /**
  42. * Run test getConfig method
  43. *
  44. * @param array $expected
  45. * @dataProvider getConfigDataProvider
  46. */
  47. public function testGetConfig($expected)
  48. {
  49. $this->config->method('isActive')
  50. ->willReturn(true);
  51. $this->config->method('isAllowToEditShippingAddress')
  52. ->willReturn(true);
  53. $this->config->method('getMerchantName')
  54. ->willReturn('Test');
  55. $this->config->method('getTitle')
  56. ->willReturn('Payment Title');
  57. $this->localeResolver->method('getLocale')
  58. ->willReturn('en_US');
  59. $this->config->method('isSkipOrderReview')
  60. ->willReturn(false);
  61. $this->config->method('getPayPalIcon')
  62. ->willReturn([
  63. 'width' => 30, 'height' => 26, 'url' => 'https://icon.test.url'
  64. ]);
  65. $this->config->method('isRequiredBillingAddress')
  66. ->willReturn(1);
  67. self::assertEquals($expected, $this->configProvider->getConfig());
  68. }
  69. /**
  70. * @return array
  71. */
  72. public function getConfigDataProvider()
  73. {
  74. return [
  75. [
  76. 'expected' => [
  77. 'payment' => [
  78. ConfigProvider::PAYPAL_CODE => [
  79. 'isActive' => true,
  80. 'title' => 'Payment Title',
  81. 'isAllowShippingAddressOverride' => true,
  82. 'merchantName' => 'Test',
  83. 'locale' => 'en_US',
  84. 'paymentAcceptanceMarkSrc' =>
  85. 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png',
  86. 'vaultCode' => ConfigProvider::PAYPAL_VAULT_CODE,
  87. 'skipOrderReview' => false,
  88. 'paymentIcon' => [
  89. 'width' => 30, 'height' => 26, 'url' => 'https://icon.test.url'
  90. ],
  91. 'isRequiredBillingAddress' => true
  92. ]
  93. ]
  94. ]
  95. ]
  96. ];
  97. }
  98. }