mirror of
https://github.com/archtechx/money.git
synced 2025-12-12 11:24:03 +00:00
Initial commit
This commit is contained in:
commit
8847454577
33 changed files with 2435 additions and 0 deletions
53
tests/Pest/HelperTest.php
Normal file
53
tests/Pest/HelperTest.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
use ArchTech\Money\Currencies\USD;
|
||||
use ArchTech\Money\Money;
|
||||
use ArchTech\Money\Tests\Currencies\CZK;
|
||||
use ArchTech\Money\Tests\Currencies\EUR;
|
||||
|
||||
test('the currency helper can be used to fetch the current currency', function () {
|
||||
expect(currency())->toBe(currencies()->getCurrent());
|
||||
});
|
||||
|
||||
test('the currency helper can be used to fetch a specific currency using its code', function () {
|
||||
currencies()->add(EUR::class);
|
||||
|
||||
expect(currency('EUR'))->toBeInstanceOf(EUR::class);
|
||||
});
|
||||
|
||||
test('the currency helper can be used to fetch a specific currency using its class', function () {
|
||||
currencies()->add(EUR::class);
|
||||
|
||||
expect(currency(EUR::class))->toBeInstanceOf(EUR::class);
|
||||
});
|
||||
|
||||
test('the money helper creates a new Money instance', function () {
|
||||
expect(money(200))->toBeInstanceOf(Money::class);
|
||||
});
|
||||
|
||||
test('the money helper accepts a string currency', function () {
|
||||
currencies()->add([EUR::class, CZK::class]);
|
||||
|
||||
expect(money(200, 'EUR')->currency())->toBeInstanceOf(EUR::class);
|
||||
expect(money(200, 'CZK')->currency())->toBeInstanceOf(CZK::class);
|
||||
});
|
||||
|
||||
test('the money helper accepts a class currency', function () {
|
||||
currencies()->add([EUR::class, CZK::class]);
|
||||
|
||||
expect(money(200, EUR::class)->currency())->toBeInstanceOf(EUR::class);
|
||||
expect(money(200, CZK::class)->currency())->toBeInstanceOf(CZK::class);
|
||||
});
|
||||
|
||||
test('the money helper accepts a currency object', function () {
|
||||
currencies()->add([EUR::class, CZK::class]);
|
||||
|
||||
expect(money(200, new EUR)->currency())->toBeInstanceOf(EUR::class);
|
||||
expect(money(200, new CZK)->currency())->toBeInstanceOf(CZK::class);
|
||||
});
|
||||
|
||||
test('the money helper falls back to the default currency', function () {
|
||||
currencies()->add(EUR::class);
|
||||
|
||||
expect(money(200)->currency())->toBeInstanceOf(USD::class);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue