Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Jul 10, 2023
1 parent 8955484 commit b2ddae1
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/Five/Payout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Billplz\Five;

use Billplz\Four\Payout as Request;

class Payout extends Request
{
//
}
2 changes: 1 addition & 1 deletion tests/Base/BankAccountTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function it_has_proper_signature()
$bank = $this->makeClient()->bank();

$this->assertInstanceOf('Billplz\Base\BankAccount', $bank);
$this->assertSame($this->apiVersion, $bank->getVersion());
$this->assertSame($this->proxyApiVersion ?? $this->apiVersion, $bank->getVersion());
}

/** @test */
Expand Down
2 changes: 1 addition & 1 deletion tests/Five/BankAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BankAccountTest extends BankAccountTestCase
*
* @var string
*/
protected $apiVersion = 'v3';
protected $proxyApiVersion = 'v3';

/** @test */
public function it_can_called_via_helper()
Expand Down
73 changes: 73 additions & 0 deletions tests/Five/PayoutTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace Billplz\Tests\Five;

use Billplz\Tests\TestCase;
use Laravie\Codex\Contracts\Response;

class PayoutTest extends TestCase
{
/**
* API Version.
*
* @var string
*/
protected $proxyApiVersion = 'v4';

/** @test */
public function it_resolve_the_correct_version()
{
$payment = $this->makeClient()->uses('Payout', 'v5');

$this->assertInstanceOf('Billplz\Four\Payout', $payment);
$this->assertSame($this->proxyApiVersion ?? $this->apiVersion, $payment->getVersion());
}

/** @test */
public function it_can_get_mass_payment()
{
$expected = '{"id":"afae4bqf","mass_payment_instruction_collection_id":"4po8no8h","bank_code":"MBBEMYKL","bank_account_number":"820808062202123","identity_number":820808062202,"name":"Michael Yap","description":"Maecenas eu placerat ante.","email":"hello@billplz.com","status":"processing","notification":false,"recipient_notification":true,"total":"2000"}';

$faker = $this->expectRequest('GET', 'mass_payment_instructions/afae4bqf')
->shouldResponseWithJson(200, $expected);

$response = $this->makeClient($faker)->uses('Payout')->get('afae4bqf');

$this->assertInstanceOf(Response::class, $response);
$this->assertSame(200, $response->getStatusCode());
$this->assertSame($expected, $response->getBody());
$this->assertNull($response->rateLimit());
$this->assertNull($response->remainingRateLimit());
$this->assertSame(0, $response->rateLimitNextReset());
}

/** @test */
public function it_can_create_mass_payment()
{
$expected = '{"id":"afae4bqf","mass_payment_instruction_collection_id":"4po8no8h","bank_code":"MBBEMYKL","bank_account_number":"820808062202123","identity_number":820808062202,"name":"Michael Yap","description":"Maecenas eu placerat ante.","email":"hello@billplz.com","status":"processing","notification":false,"recipient_notification":true,"total":"2000"}';

$payload = [
'name' => 'Michael Yap',
'description' => 'Maecenas eu placerat ante.',
'total' => 2000,
'mass_payment_instruction_collection_id' => '4po8no8h',
'bank_code' => 'MBBEMYKL',
'bank_account_number' => '820808062202123',
'identity_number' => '820808062202',
];

$faker = $this->expectRequest('POST', 'mass_payment_instructions', [], $payload)
->shouldResponseWithJson(200, $expected);

$response = $this->makeClient($faker)->uses('Payout')->create(
'4po8no8h', 'MBBEMYKL', '820808062202123', '820808062202', 'Michael Yap', 'Maecenas eu placerat ante.', 2000
);

$this->assertInstanceOf(Response::class, $response);
$this->assertSame(200, $response->getStatusCode());
$this->assertSame($expected, $response->getBody());
$this->assertNull($response->rateLimit());
$this->assertNull($response->remainingRateLimit());
$this->assertSame(0, $response->rateLimitNextReset());
}
}
4 changes: 2 additions & 2 deletions tests/Five/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class WebhookTest extends TestCase
*
* @var string
*/
protected $apiVersion = 'v4';
protected $proxyApiVersion = 'v4';

/** @test */
public function it_resolve_the_correct_version()
{
$payment = $this->makeClient()->uses('Webhook', 'v5');

$this->assertInstanceOf('Billplz\Four\Webhook', $payment);
$this->assertSame('v4', $payment->getVersion());
$this->assertSame($this->proxyApiVersion ?? $this->apiVersion, $payment->getVersion());
}

/** @test */
Expand Down
2 changes: 1 addition & 1 deletion tests/Four/BankAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public function it_can_called_via_helper()

$this->assertInstanceOf('Billplz\Four\BankAccount', $bank);
$this->assertInstanceOf('Billplz\Three\BankAccount', $bank);
$this->assertSame('v3', $bank->getVersion());
$this->assertSame($this->proxyApiVersion ?? $this->apiVersion, $bank->getVersion());
}
}
2 changes: 1 addition & 1 deletion tests/Four/PayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function it_resolve_the_correct_version()
$payment = $this->makeClient()->uses('Payout', 'v4');

$this->assertInstanceOf('Billplz\Four\Payout', $payment);
$this->assertSame('v4', $payment->getVersion());
$this->assertSame($this->proxyApiVersion ?? $this->apiVersion, $payment->getVersion());
}

/** @test */
Expand Down
2 changes: 1 addition & 1 deletion tests/Four/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function it_resolve_the_correct_version()
$payment = $this->makeClient()->uses('Webhook', 'v4');

$this->assertInstanceOf('Billplz\Four\Webhook', $payment);
$this->assertSame('v4', $payment->getVersion());
$this->assertSame($this->proxyApiVersion ?? $this->apiVersion, $payment->getVersion());
}

/** @test */
Expand Down

0 comments on commit b2ddae1

Please sign in to comment.