fix: fiabiliser les fiches animales et vaccinations
This commit is contained in:
parent
f45cfc40f2
commit
361bef8561
20 changed files with 157 additions and 65 deletions
|
|
@ -167,6 +167,37 @@ try {
|
|||
$assert(!ShelterRoomService::accepts($room, ['species' => 'chat', 'sex' => 'F', 'fiv' => 1]));
|
||||
$assert(!ShelterRoomService::accepts($room, ['species' => 'chat', 'sex' => 'M', 'fiv' => 0]));
|
||||
});
|
||||
$test('Une salle configurable peut être enregistrée sur un animal', function () use ($db, $assert): void {
|
||||
$schema = (string) $db->query("SELECT sql FROM sqlite_master WHERE type='table' AND name='animals'")->fetchColumn();
|
||||
$assert(!str_contains($schema, "refuge_room IN ('silver', 'twix')"), 'Ancienne contrainte de salle encore active');
|
||||
$code = 'TEST-ROOM-' . bin2hex(random_bytes(3));
|
||||
$db->prepare("INSERT INTO animals(name,internal_code,refuge_room) VALUES('Test salle',:code,'nouvelle-salle')")->execute([':code' => $code]);
|
||||
$id = (int) $db->lastInsertId();
|
||||
$assert((string) $db->query('SELECT refuge_room FROM animals WHERE id=' . $id)->fetchColumn() === 'nouvelle-salle');
|
||||
$db->prepare('DELETE FROM animals WHERE id=:id')->execute([':id' => $id]);
|
||||
});
|
||||
$test('Les quatre états I-CAD sont acceptés', function () use ($db, $assert): void {
|
||||
$code = 'TEST-ICAD-' . bin2hex(random_bytes(3));
|
||||
$db->prepare("INSERT INTO animals(name,internal_code,identification_registration_status) VALUES('Test I-CAD',:code,'unknown')")
|
||||
->execute([':code' => $code]);
|
||||
$id = (int) $db->lastInsertId();
|
||||
foreach (['unknown', 'registered', 'change_pending', 'owner_changed'] as $status) {
|
||||
$db->prepare('UPDATE animals SET identification_registration_status=:status WHERE id=:id')
|
||||
->execute([':status' => $status, ':id' => $id]);
|
||||
$assert(
|
||||
(string) $db->query('SELECT identification_registration_status FROM animals WHERE id=' . $id)->fetchColumn() === $status,
|
||||
'État I-CAD refusé : ' . $status,
|
||||
);
|
||||
}
|
||||
$db->prepare('DELETE FROM animals WHERE id=:id')->execute([':id' => $id]);
|
||||
});
|
||||
$test('La vaccination repose sur le cabinet vétérinaire', function () use ($assert): void {
|
||||
$modal = (string) file_get_contents(dirname(__DIR__) . '/app/Views/_animal_show_modals.php');
|
||||
$summary = (string) file_get_contents(dirname(__DIR__) . '/app/Views/_animal_show_medical.php');
|
||||
$assert(!str_contains($modal, 'name="administered_by_user_id"'));
|
||||
$assert(!str_contains($modal, 'name="administered_by_name"'));
|
||||
$assert(str_contains($summary, "\$v['clinic_name']"));
|
||||
});
|
||||
$test('Les paramètres sont enregistrés et relus', function () use ($assert): void {
|
||||
AppSettings::save(['association_name' => 'Refuge Test', 'app_language' => 'en'], null);
|
||||
$assert(AppSettings::get('association_name') === 'Refuge Test');
|
||||
|
|
|
|||
Loading…
Reference in a new issue