From 1fb607f35293421dc9d4e362c11707f38ad5add7 Mon Sep 17 00:00:00 2001 From: lukinovec Date: Wed, 15 Feb 2023 17:41:33 +0100 Subject: [PATCH] Bring back immutability tests --- tests/Pest/MoneyTest.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Pest/MoneyTest.php b/tests/Pest/MoneyTest.php index 7d6bf41..e3627ba 100644 --- a/tests/Pest/MoneyTest.php +++ b/tests/Pest/MoneyTest.php @@ -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');