Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
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
10pest()->group('unit');
11
12use AppDemo\Loan\Domain\Exception\LoanNotOwnedByUserException;
13use Phexium\Domain\Id\TimestampId;
14
15describe('Creation', function (): void {
16    it('creates an exception with loan and user ID in message', function (): void {
17        $exception = LoanNotOwnedByUserException::forLoanAndUser(
18            TimestampId::from(123),
19            TimestampId::from(234)
20        );
21
22        expect($exception->getMessage())->toContain('ID 123')
23            ->and($exception->getMessage())->toContain('user 234')
24        ;
25
26        expect(fn () => throw $exception)
27            ->toThrow(LoanNotOwnedByUserException::class)
28        ;
29    });
30});