fix: étendre la recherche aux identifications
This commit is contained in:
parent
361bef8561
commit
a932db0ace
8 changed files with 66 additions and 12 deletions
|
|
@ -481,6 +481,24 @@ try {
|
|||
$agenda = GlobalSearchService::search('Mission bénévole');
|
||||
$assert(!empty($agenda['agenda']), 'Événement absent de la recherche');
|
||||
});
|
||||
$test('La recherche ignore la casse et les accents et retrouve les identifiants', function () use ($db, $assert): void {
|
||||
$code = 'TEST-SEARCH-' . bin2hex(random_bytes(3));
|
||||
$chip = '250269610987654';
|
||||
$db->prepare("INSERT INTO animals(name,internal_code,chip_id,identification_type) VALUES('Bréhat',:code,:chip,'microchip')")
|
||||
->execute([':code' => $code, ':chip' => $chip]);
|
||||
$id = (int) $db->lastInsertId();
|
||||
foreach (['Bréhat', 'Brehat', 'BREHAT', 'bReHaT', $chip] as $query) {
|
||||
$results = GlobalSearchService::search($query);
|
||||
$ids = array_map(
|
||||
static fn(array $row): int => (int) filter_var($row['url'], FILTER_SANITIZE_NUMBER_INT),
|
||||
$results['animals'] ?? [],
|
||||
);
|
||||
$assert(in_array($id, $ids, true), 'Recherche infructueuse : ' . $query);
|
||||
}
|
||||
$result = GlobalSearchService::search($chip)['animals'][0] ?? [];
|
||||
$assert(str_contains((string) ($result['detail'] ?? ''), $chip), 'Numéro absent du résultat');
|
||||
$db->prepare('DELETE FROM animals WHERE id=:id')->execute([':id' => $id]);
|
||||
});
|
||||
$test('Une sauvegarde ZIP contient une base et un manifeste', function () use (&$createdBackup, $assert): void {
|
||||
if (!class_exists('ZipArchive')) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue