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