Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
18 / 18 |
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 | use Phexium\Domain\Specification\AlwaysTrueSpecification; |
| 11 | |
| 12 | test('toSql() returns "1 = 1" condition', function (): void { |
| 13 | $spec = new AlwaysTrueSpecification(); |
| 14 | |
| 15 | $result = $spec->toSql(); |
| 16 | |
| 17 | expect($result)->toBeArray(); |
| 18 | expect($result)->toHaveKey('sql'); |
| 19 | expect($result)->toHaveKey('params'); |
| 20 | expect($result['sql'])->toBe('1 = 1'); |
| 21 | expect($result['params'])->toBe([]); |
| 22 | }); |
| 23 | |
| 24 | test('toInMemoryFilter() returns callable that always returns true', function (): void { |
| 25 | $spec = new AlwaysTrueSpecification(); |
| 26 | |
| 27 | $filter = $spec->toInMemoryFilter(); |
| 28 | |
| 29 | expect($filter)->toBeCallable(); |
| 30 | |
| 31 | $row1 = ['id' => 1, 'name' => 'Foo']; |
| 32 | expect($filter($row1))->toBeTrue(); |
| 33 | |
| 34 | $row2 = ['id' => 2, 'name' => 'Bar']; |
| 35 | expect($filter($row2))->toBeTrue(); |
| 36 | }); |