Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
16 / 16 |
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 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | pest()->group('unit'); |
| 11 | |
| 12 | use AppDemo\Library\Application\Query\CreateBookResponse; |
| 13 | use AppDemo\Library\Presentation\CreateBookHtmlPresenter; |
| 14 | use AppDemo\Library\Presentation\CreateBookHtmlViewModel; |
| 15 | |
| 16 | describe('Presentation', function (): void { |
| 17 | it('passes through form values and errors', function (): void { |
| 18 | $formValues = ['title' => 'Clean Code', 'author' => 'Robert C. Martin']; |
| 19 | $errors = ['isbn' => 'ISBN is required']; |
| 20 | $response = new CreateBookResponse( |
| 21 | formValues: $formValues, |
| 22 | errors: $errors |
| 23 | ); |
| 24 | |
| 25 | $viewModel = new CreateBookHtmlPresenter()->present($response)->getViewModel(); |
| 26 | |
| 27 | expect($viewModel)->toBeInstanceOf(CreateBookHtmlViewModel::class) |
| 28 | ->and($viewModel->formValues)->toBe($formValues) |
| 29 | ->and($viewModel->errors)->toBe($errors) |
| 30 | ; |
| 31 | }); |
| 32 | }); |