Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
22 / 22 |
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\DetailBookResponse; |
| 13 | use AppDemo\Library\Presentation\DetailBookJsonPresenter; |
| 14 | |
| 15 | describe('Presentation', function (): void { |
| 16 | it('maps response to array with book key', function (): void { |
| 17 | $response = new DetailBookResponse( |
| 18 | id: 42, |
| 19 | title: 'Clean Code', |
| 20 | author: 'Robert C. Martin', |
| 21 | isbn: '9780134494166', |
| 22 | status: 'available' |
| 23 | ); |
| 24 | |
| 25 | $viewModel = new DetailBookJsonPresenter()->present($response)->getViewModel(); |
| 26 | |
| 27 | expect($viewModel)->toBeArray() |
| 28 | ->and($viewModel['book'])->toBe([ |
| 29 | 'id' => 42, |
| 30 | 'title' => 'Clean Code', |
| 31 | 'author' => 'Robert C. Martin', |
| 32 | 'isbn' => '9780134494166', |
| 33 | 'status' => 'available', |
| 34 | ]) |
| 35 | ; |
| 36 | }); |
| 37 | }); |