-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec3aa80
commit 6668e7e
Showing
1 changed file
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Omise\Payment\Test\Unit\Model\Api; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Omise\Payment\Model\Api\Capabilities; | ||
use Omise\Payment\Model\Config\Config; | ||
use Mockery as m; | ||
|
||
class CapabilitiesTest extends TestCase | ||
{ | ||
private $configMock; | ||
private $omiseCapabilitiesMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->configMock = m::mock(Config::class); | ||
$this->configMock->shouldReceive('canInitialize')->andReturn(true); | ||
$this->omiseCapabilitiesMock = m::mock('alias:OmiseCapabilities'); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
m::close(); | ||
} | ||
|
||
/** | ||
* @covers Omise\Payment\Model\Api\Capabilities | ||
*/ | ||
public function testGetInstallmentMinLimit() | ||
{ | ||
$data = [ | ||
'limits' => [ | ||
'installment_amount' => [ | ||
'min' => 3000 | ||
] | ||
] | ||
]; | ||
$this->omiseCapabilitiesMock->shouldReceive('retrieve')->andReturn($data); | ||
$capabilities = new Capabilities($this->configMock); | ||
$result = $capabilities->getInstallmentMinLimit(); | ||
|
||
$this->assertEquals($data['limits']['installment_amount']['min'], $result); | ||
} | ||
|
||
/** | ||
* @covers Omise\Payment\Model\Api\Capabilities | ||
*/ | ||
public function testGetInstallmentMinLimitReturnsZeroIfCapabilitiesIsNotSet() | ||
{ | ||
$this->omiseCapabilitiesMock->shouldReceive('retrieve')->andReturn(null); | ||
$capabilities = new Capabilities($this->configMock); | ||
$result = $capabilities->getInstallmentMinLimit(); | ||
|
||
$this->assertEquals(0, $result); | ||
} | ||
} |