Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
18 / 18
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 AppDemo\User\Domain\UserGroup;
11use Tests\AppDemo\Fixture\UserMother;
12
13test('User exposes its properties', function (): void {
14    $user = UserMother::create(id: 123, email: 'user@example.com', hashedPassword: '$plain$hashedvalue', group: UserGroup::User);
15
16    expect($user->getId()->getValue())->toBe(123)
17        ->and($user->getEmail()->getValue())->toBe('user@example.com')
18        ->and($user->getHashedPassword()->getValue())->toBe('$plain$hashedvalue')
19        ->and($user->getGroup())->toBe(UserGroup::User)
20    ;
21});
22
23test('Two users with the same ID are equal', function (): void {
24    $user1 = UserMother::user(123);
25    $user2 = UserMother::user(123);
26
27    expect($user1->equals($user2))->toBeTrue();
28});
29
30test('Two users with different IDs are not equal', function (): void {
31    $user1 = UserMother::user(123);
32    $user2 = UserMother::user(234);
33
34    expect($user1->equals($user2))->toBeFalse();
35});