Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
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
8declare(strict_types=1);
9
10use Tests\Phexium\Fake\Domain\Specification\NameSpecification as FakeNameSpecification;
11
12test('toSql() returns correct SQL and params', function (): void {
13    $specification = new FakeNameSpecification('Foo');
14
15    $result = $specification->toSql();
16
17    expect($result)->toBeArray();
18    expect($result)->toHaveKey('sql');
19    expect($result)->toHaveKey('params');
20    expect($result['sql'])->toBe('name = :name');
21    expect($result['params'])->toBe(['name' => 'Foo']);
22});
23
24test('toInMemoryFilter() returns callable that filters by name', function (): void {
25    $specification = new FakeNameSpecification('Foo');
26
27    $filter = $specification->toInMemoryFilter();
28
29    expect($filter)->toBeCallable();
30
31    $matchingRow = ['id' => 1, 'name' => 'Foo'];
32    expect($filter($matchingRow))->toBeTrue();
33
34    $nonMatchingRow = ['id' => 2, 'name' => 'Bar'];
35    expect($filter($nonMatchingRow))->toBeFalse();
36});