Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
14 / 14 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| UserMother | |
100.00% |
14 / 14 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| admin | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| user | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | // ╔════════════════════════════════════════════════════════════╗ |
| 4 | // ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║ |
| 5 | // ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com> ║ |
| 6 | // ╚════════════════════════════════════════════════════════════╝ |
| 7 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | namespace Tests\AppDemo\Fixture; |
| 11 | |
| 12 | use AppDemo\User\Domain\Email; |
| 13 | use AppDemo\User\Domain\HashedPassword; |
| 14 | use AppDemo\User\Domain\User; |
| 15 | use AppDemo\User\Domain\UserGroup; |
| 16 | use Phexium\Domain\Id\TimestampId; |
| 17 | |
| 18 | final class UserMother |
| 19 | { |
| 20 | public static function admin(int $id = 1): User |
| 21 | { |
| 22 | return self::create( |
| 23 | id: $id, |
| 24 | group: UserGroup::Admin |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | public static function user(int $id = 1): User |
| 29 | { |
| 30 | return self::create( |
| 31 | id: $id, |
| 32 | group: UserGroup::User |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | public static function create( |
| 37 | int $id = 1, |
| 38 | string $email = 'user@example.com', |
| 39 | string $hashedPassword = '$plain$password', |
| 40 | UserGroup $group = UserGroup::User |
| 41 | ): User { |
| 42 | return new User( |
| 43 | new TimestampId($id), |
| 44 | Email::fromString($email), |
| 45 | HashedPassword::fromHash($hashedPassword), |
| 46 | $group |
| 47 | ); |
| 48 | } |
| 49 | } |