Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
30 / 30 |
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\Domain\BookStatus; |
| 13 | |
| 14 | describe('Values', function (): void { |
| 15 | it('returns correct human-readable labels', function (): void { |
| 16 | expect(BookStatus::Available->label())->toBe('Available') |
| 17 | ->and(BookStatus::Borrowed->label())->toBe('Borrowed') |
| 18 | ; |
| 19 | }); |
| 20 | |
| 21 | it('identifies available status correctly', function (): void { |
| 22 | expect(BookStatus::Available->isAvailable())->toBeTrue() |
| 23 | ->and(BookStatus::Borrowed->isAvailable())->toBeFalse() |
| 24 | ; |
| 25 | }); |
| 26 | |
| 27 | it('identifies borrowed status correctly', function (): void { |
| 28 | expect(BookStatus::Borrowed->isBorrowed())->toBeTrue() |
| 29 | ->and(BookStatus::Available->isBorrowed())->toBeFalse() |
| 30 | ; |
| 31 | }); |
| 32 | }); |
| 33 | |
| 34 | describe('Behavior', function (): void { |
| 35 | it('allows borrowing only for available status', function (): void { |
| 36 | expect(BookStatus::Available->canBeBorrowed())->toBeTrue() |
| 37 | ->and(BookStatus::Borrowed->canBeBorrowed())->toBeFalse() |
| 38 | ; |
| 39 | }); |
| 40 | |
| 41 | it('allows returning only for borrowed status', function (): void { |
| 42 | expect(BookStatus::Borrowed->canBeReturned())->toBeTrue() |
| 43 | ->and(BookStatus::Available->canBeReturned())->toBeFalse() |
| 44 | ; |
| 45 | }); |
| 46 | }); |