PHP Classes

File: tests/Unit/Data/PayoutTest.php

Recommend this page to a friend!
  Packages of Daryl Legion   PayRex Laravel   tests/Unit/Data/PayoutTest.php   Download  
File: tests/Unit/Data/PayoutTest.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PayRex Laravel
Request payments using the PayRex service
Author: By
Last change:
Date: 7 months ago
Size: 1,687 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use LegionHQ\LaravelPayrex\Data\Payout;
use LegionHQ\LaravelPayrex\Enums\PayoutStatus;

it('hydrates all properties', function () {
    $payout = Payout::from([
        'id' => 'po_test123',
        'resource' => 'payout',
        'amount' => 500000,
        'net_amount' => 495000,
        'status' => 'successful',
        'destination' => ['account_name' => 'My Company XYZ', 'account_number' => '123123217362122', 'bank_name' => 'BPI'],
        'livemode' => false,
    ]);

    expect($payout->id)->toBe('po_test123')
        ->and($payout->resource)->toBe('payout')
        ->and($payout->amount)->toBe(500000)
        ->and($payout->netAmount)->toBe(495000)
        ->and($payout->destination)->toBe(['account_name' => 'My Company XYZ', 'account_number' => '123123217362122', 'bank_name' => 'BPI'])
        ->and($payout->livemode)->toBeFalse();
});

it('casts status to PayoutStatus enum', function () {
    expect((Payout::from(['id' => 'po_1', 'resource' => 'payout', 'status' => 'pending']))->status)->toBe(PayoutStatus::Pending)
        ->and((Payout::from(['id' => 'po_2', 'resource' => 'payout', 'status' => 'in_transit']))->status)->toBe(PayoutStatus::InTransit)
        ->and((Payout::from(['id' => 'po_3', 'resource' => 'payout', 'status' => 'failed']))->status)->toBe(PayoutStatus::Failed)
        ->and((Payout::from(['id' => 'po_4', 'resource' => 'payout', 'status' => 'successful']))->status)->toBe(PayoutStatus::Successful);
});

it('returns null for unknown status values', function () {
    $payout = Payout::from(['id' => 'po_1', 'resource' => 'payout', 'status' => 'nonexistent']);

    expect($payout->status)->toBeNull();
});