1
0
Fork 0
mirror of https://github.com/archtechx/money.git synced 2025-12-12 11:24:03 +00:00

cents() method

This commit is contained in:
Samuel Štancl 2021-11-28 18:38:54 +01:00
parent 8dc5287868
commit f5bf658155
2 changed files with 24 additions and 0 deletions

View file

@ -210,6 +210,21 @@ test('the is method compares both the value and the currency', function () {
)->toBeFalse();
});
test('the cents from the decimal value can be fetched using the cents method', function () {
currencies()->add(CZK::class);
expect(money(100)->cents())->toBeInstanceOf(Money::class);
expect(money(1234, USD::class)->cents()->value())->toBe(34);
expect(money(1234, CZK::class)->cents()->value())->toBe(34);
expect(money(100, USD::class)->cents()->value())->toBe(0);
expect(money(100, CZK::class)->cents()->value())->toBe(0);
expect(money(123456789, USD::class)->cents()->value())->toBe(89);
expect(money(123456789, CZK::class)->cents()->value())->toBe(89);
});
test('money can be serialized to JSON', function () {
currencies()->add(CZK::class);