Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
26 / 26
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10use Tests\Phexium\Fake\Domain\IntValueObject;
11use Tests\Phexium\Fake\Domain\StringValueObject;
12
13test('Can create an int VO using static factory method', function (): void {
14    $int = IntValueObject::fromInt(123);
15
16    expect($int->getValue())->toBe(123);
17    expect($int->jsonSerialize())->toBe(123);
18    expect((string) $int)->toBe('123');
19});
20
21test('Two int VO with same value are equal', function (): void {
22    $int1 = IntValueObject::fromInt(123);
23    $int2 = IntValueObject::fromInt(123);
24
25    expect($int1->equals($int2))->toBeTrue();
26});
27
28test('Two int VO with different values are not equal', function (): void {
29    $int1 = IntValueObject::fromInt(123);
30    $int2 = IntValueObject::fromInt(234);
31
32    expect($int1->equals($int2))->toBeFalse();
33});
34
35test('An int VO and another value object are not equal', function (): void {
36    $other = StringValueObject::fromString('FooBar');
37    $object = IntValueObject::fromInt(123);
38
39    expect($object->equals($other))->toBeFalse();
40});
41
42it('throws exception for empty int VO', function (): void {
43    expect(fn (): IntValueObject => IntValueObject::fromInt(0))
44        ->toThrow(InvalidArgumentException::class, 'IntValueObject cannot be empty')
45    ;
46});