mirror of
https://github.com/archtechx/money.git
synced 2025-12-12 11:24:03 +00:00
Bring back immutability tests
This commit is contained in:
parent
2bf0c0ecc6
commit
1fb607f352
1 changed files with 20 additions and 0 deletions
|
|
@ -6,6 +6,26 @@ use ArchTech\Money\Money;
|
||||||
use ArchTech\Money\Tests\Currencies\CZK;
|
use ArchTech\Money\Tests\Currencies\CZK;
|
||||||
use ArchTech\Money\Tests\Currencies\EUR;
|
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 () {
|
test('money can be created from a decimal value', function () {
|
||||||
$money = Money::fromDecimal(10.0, 'USD');
|
$money = Money::fromDecimal(10.0, 'USD');
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue