Skip to content

Commit

Permalink
Add test for Model/Api/Capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishgurung committed Sep 17, 2024
1 parent ec3aa80 commit 6668e7e
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions Test/Unit/Model/Api/CapabilitiesTest.php
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);
}
}

0 comments on commit 6668e7e

Please sign in to comment.