Skip to content

Commit 3ab543e

Browse files
dmytro-chronak2ram
authored andcommitted
Added unit test for AvailabilityChecker
1 parent 50503f2 commit 3ab543e

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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

Comments
 (0)