Skip to content

Commit

Permalink
Fix: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Aug 30, 2023
1 parent 635f8b8 commit 03dc196
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions tests/Unit/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,66 @@ public function test_it_can_determine_if_reverse_charge_applies()

$this->assertTrue($invoice->reverseChargeApplies());
}
public function test_it_can_determine_if_is_deleted(): void
{
$customerId = 'foo';

$stripeInvoice = new StripeInvoice();

$stripeInvoice->customer = $customerId;
$stripeInvoice->status = StripeInvoice::STATUS_DELETED;

$user = new User();

$user->stripe_id = $customerId;

$invoice = new Invoice($user, $stripeInvoice);

$this->assertTrue($invoice->isDeleted());
}

/**
* @dataProvider provideInvoiceStatusNotDeleted
*/
public function test_it_can_determine_if_is_not_deleted(string $invoiceStatus): void
{
$customerId = 'foo';

$stripeInvoice = new StripeInvoice();

$stripeInvoice->customer = $customerId;
$stripeInvoice->status = $invoiceStatus;

$user = new User();

$user->stripe_id = $customerId;

$invoice = new Invoice($user, $stripeInvoice);

$this->assertFalse($invoice->isDeleted());
}


/**
* @return array<string, array{0: string}>
*/
public function provideInvoiceStatusNotDeleted(): array
{
$invoiceStatuses = [
StripeInvoice::STATUS_DRAFT,
StripeInvoice::STATUS_OPEN,
StripeInvoice::STATUS_PAID,
StripeInvoice::STATUS_UNCOLLECTIBLE,
StripeInvoice::STATUS_VOID,
];

return array_combine(
$invoiceStatuses,
array_map(static function (string $invoiceStatus): array {
return [
$invoiceStatus
];
}, $invoiceStatuses)
);
}
}

0 comments on commit 03dc196

Please sign in to comment.