1
0
Fork 0
mirror of https://github.com/archtechx/money.git synced 2025-12-12 19:34:02 +00:00

Bring back immutability tests

This commit is contained in:
lukinovec 2023-02-15 17:41:33 +01:00
parent 2bf0c0ecc6
commit 1fb607f352

View file

@ -6,6 +6,26 @@ use ArchTech\Money\Money;
use ArchTech\Money\Tests\Currencies\CZK;
use ArchTech\Money\Tests\Currencies\EUR;
test('Money value is immutable', function () {
$money = money(100);
try {
$money->value = 200;
} catch (\Throwable $th) {
expect($th->getMessage())->toStartWith('Cannot access protected property');
}
});
test('Money currency is immutable', function () {
$money = money(100);
try {
$money->currency = 'EUR';
} catch (\Throwable $th) {
expect($th->getMessage())->toStartWith('Cannot access protected property');
}
});
test('money can be created from a decimal value', function () {
$money = Money::fromDecimal(10.0, 'USD');