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

feature: money instance creation from a formatted string

This commit is contained in:
Gaurav 2022-03-09 12:50:04 +05:30
parent 8bdf0d1a2b
commit 38c6326a4d
4 changed files with 53 additions and 2 deletions

View file

@ -147,6 +147,18 @@ test('money can be formatted without rounding', function () {
)->toBe('10,34 Kč');
});
test('money can be created from a formatted string', function () {
$money = Money::fromFormatted('$10.40');
expect($money->value())->toBe(1040);
});
test('money can be created from a raw formatted string', function () {
currencies()->add([CZK::class]);
$money = Money::fromFormatted('1 234,56 Kč', CZK::class);
expect($money->value())->toBe(123456);
});
test('converting money to a string returns the formatted string', function () {
expect(
(string) Money::fromDecimal(10.00, USD::class)