PHP Classes

File: tests/Unit/Data/CustomerTest.php

Recommend this page to a friend!
  Packages of Daryl Legion   PayRex Laravel   tests/Unit/Data/CustomerTest.php   Download  
File: tests/Unit/Data/CustomerTest.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,154 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

use
LegionHQ\LaravelPayrex\Data\Customer;

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

   
expect($customer->id)->toBe('cus_xxxxx')
        ->
and($customer->resource)->toBe('customer')
        ->
and($customer->name)->toBe('Juan Dela Cruz')
        ->
and($customer->email)->toBe('juan@gmail.com')
        ->
and($customer->currency)->toBe('PHP')
        ->
and($customer->billingStatementPrefix)->toBe('PKYG9MA2')
        ->
and($customer->nextBillingStatementSequenceNumber)->toBe('1')
        ->
and($customer->billing)->toBeNull()
        ->
and($customer->livemode)->toBeFalse()
        ->
and($customer->metadata)->toBeNull();
});

it('handles missing optional properties gracefully', function () {
   
$customer = Customer::from(['id' => 'cus_1', 'resource' => 'customer']);

   
expect($customer->name)->toBeNull()
        ->
and($customer->email)->toBeNull()
        ->
and($customer->currency)->toBeNull()
        ->
and($customer->billingStatementPrefix)->toBeNull()
        ->
and($customer->billing)->toBeNull();
});