Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
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\Application\Query\MyLoansResponse;
13use AppDemo\Loan\Presentation\MyLoansHtmlPresenter;
14use AppDemo\Loan\Presentation\MyLoansHtmlViewModel;
15
16describe('Presentation', function (): void {
17    it('maps loans and calculates count', function (): void {
18        $loans = [['id' => 1], ['id' => 2], ['id' => 3]];
19        $response = new MyLoansResponse(loans: $loans);
20
21        $viewModel = new MyLoansHtmlPresenter()->present($response)->getViewModel();
22
23        expect($viewModel)->toBeInstanceOf(MyLoansHtmlViewModel::class)
24            ->and($viewModel->loans)->toBe($loans)
25            ->and($viewModel->count)->toBe(3)
26        ;
27    });
28});