PHP Classes

File: tests/Unit/Data/BillingStatementLineItemTest.php

Recommend this page to a friend!
  Packages of Daryl Legion   PayRex Laravel   tests/Unit/Data/BillingStatementLineItemTest.php   Download  
File: tests/Unit/Data/BillingStatementLineItemTest.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: 13 days ago
Size: 1,000 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
LegionHQ\LaravelPayrex\Data\BillingStatementLineItem;

it('hydrates all properties from fixture', function () {
   
$data = loadFixture('billing_statement_line_item/created.json');
   
$item = BillingStatementLineItem::from($data);

   
expect($item->id)->toBe('bstm_li_xxxxx')
        ->
and($item->resource)->toBe('billing_statement_line_item')
        ->
and($item->description)->toBe('Product X')
        ->
and($item->unitPrice)->toBe(10000)
        ->
and($item->quantity)->toBe(5)
        ->
and($item->billingStatementId)->toBe('bstm_xxxxx')
        ->
and($item->livemode)->toBeFalse();
});

it('handles missing optional properties gracefully', function () {
   
$item = BillingStatementLineItem::from(['id' => 'bstm_li_1', 'resource' => 'billing_statement_line_item']);

   
expect($item->description)->toBeNull()
        ->
and($item->unitPrice)->toBeNull()
        ->
and($item->quantity)->toBeNull()
        ->
and($item->billingStatementId)->toBeNull();
});