AvailabilityCheckerTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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\Braintree\Test\Unit\Model\InstantPurchase\CreditCard;
  8. use Magento\Braintree\Gateway\Config\Config;
  9. use Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker;
  10. /**
  11. * @covers \Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker
  12. */
  13. class AvailabilityCheckerTest extends \PHPUnit\Framework\TestCase
  14. {
  15. /**
  16. * Testable Object
  17. *
  18. * @var AvailabilityChecker
  19. */
  20. private $availabilityChecker;
  21. /**
  22. * @var Config|\PHPUnit_Framework_MockObject_MockObject
  23. */
  24. private $configMock;
  25. /**
  26. * Set Up
  27. *
  28. * @return void
  29. */
  30. protected function setUp()
  31. {
  32. $this->configMock = $this->createMock(Config::class);
  33. $this->availabilityChecker = new AvailabilityChecker($this->configMock);
  34. }
  35. /**
  36. * Test isAvailable method
  37. *
  38. * @dataProvider isAvailableDataProvider
  39. *
  40. * @param bool $isVerify3DSecure
  41. * @param bool $expected
  42. *
  43. * @return void
  44. */
  45. public function testIsAvailable(bool $isVerify3DSecure, bool $expected)
  46. {
  47. $this->configMock->expects($this->once())->method('isVerify3DSecure')->willReturn($isVerify3DSecure);
  48. $actual = $this->availabilityChecker->isAvailable();
  49. self::assertEquals($expected, $actual);
  50. }
  51. /**
  52. * Data provider for isAvailable method test
  53. *
  54. * @return array
  55. */
  56. public function isAvailableDataProvider()
  57. {
  58. return [
  59. [true, false],
  60. [false, true],
  61. ];
  62. }
  63. }