toBeInstanceOf(MoneyAmount::class) ->and($amount->value)->toBe($money); }); it('implements equals by delegating to the wrapped Money', function () use ($money, $secondMoney): void { // GIVEN / WHEN $amount1 = new MoneyAmount($money); $amount2 = new MoneyAmount($money); $amount3 = new MoneyAmount($secondMoney); // THEN expect($amount1->equals($amount2))->toBeTrue() ->and($amount1->equals($amount3))->toBeFalse() ->and($amount1->equals(null))->toBeFalse(); }); it('converts to string by delegating to the wrapped Money', function () use ($money): void { // GIVEN / WHEN $amount = new MoneyAmount($money); // THEN expect((string) $amount)->toBe((string) $amount->value); }); it('accepts the minimum amount of 0.01€', function () use ($minimumMoney): void { // GIVEN / WHEN $amount = new MoneyAmount($minimumMoney); // THEN expect($amount->value)->toBe($minimumMoney); }); it('accepts the maximum amount of 3.00€', function () use ($money): void { // GIVEN / WHEN $amount = new MoneyAmount($money); // THEN expect($amount->value)->toBe($money); }); it('throws when the amount is zero', function () use ($zeroMoney): void { // GIVEN / WHEN / THEN expect(fn (): MoneyAmount => new MoneyAmount($zeroMoney)) ->toThrow(\DomainException::class, 'Money amount must be between 0.01€ and 3.00€'); }); it('throws when the amount is above 3.00€', function () use ($aboveLimitMoney): void { // GIVEN / WHEN / THEN expect(fn (): MoneyAmount => new MoneyAmount($aboveLimitMoney)) ->toThrow(\DomainException::class, 'Money amount must be between 0.01€ and 3.00€'); }); });