|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Braintree\Test\Unit\Model\InstantPurchase\CreditCard; |
| 9 | + |
| 10 | +use Magento\Braintree\Gateway\Config\Config; |
| 11 | +use Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker; |
| 12 | + |
| 13 | +/** |
| 14 | + * @covers \Magento\Braintree\Model\InstantPurchase\CreditCard\AvailabilityChecker |
| 15 | + */ |
| 16 | +class AvailabilityCheckerTest extends \PHPUnit\Framework\TestCase |
| 17 | +{ |
| 18 | + /** |
| 19 | + * Testable Object |
| 20 | + * |
| 21 | + * @var AvailabilityChecker |
| 22 | + */ |
| 23 | + private $availabilityChecker; |
| 24 | + |
| 25 | + /** |
| 26 | + * @var Config|\PHPUnit_Framework_MockObject_MockObject |
| 27 | + */ |
| 28 | + private $configMock; |
| 29 | + |
| 30 | + /** |
| 31 | + * Se Up |
| 32 | + * |
| 33 | + * @return void |
| 34 | + */ |
| 35 | + protected function setUp() |
| 36 | + { |
| 37 | + $this->configMock = $this->createMock(Config::class); |
| 38 | + $this->availabilityChecker = new AvailabilityChecker($this->configMock); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Test isAvailable method |
| 43 | + * |
| 44 | + * @dataProvider isAvailableDataProvider |
| 45 | + * |
| 46 | + * @param bool $isVerify3DSecure |
| 47 | + * @param bool $expected |
| 48 | + * |
| 49 | + * @return void |
| 50 | + */ |
| 51 | + public function testIsAvailable(bool $isVerify3DSecure, bool $expected) |
| 52 | + { |
| 53 | + $this->configMock->expects($this->once())->method('isVerify3DSecure')->willReturn($isVerify3DSecure); |
| 54 | + $actual = $this->availabilityChecker->isAvailable(); |
| 55 | + self::assertEquals($expected, $actual); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Data provider for isAvailable method test |
| 60 | + * |
| 61 | + * @return array |
| 62 | + */ |
| 63 | + public function isAvailableDataProvider() |
| 64 | + { |
| 65 | + return [ |
| 66 | + [true, false], |
| 67 | + [false, true], |
| 68 | + ]; |
| 69 | + } |
| 70 | +} |
0 commit comments