feat: tag management tests, maintenance mode polish, répertoire pagination fix

- tests/Unit/DatabaseTest.php: tests 5-7 for findOrCreateTag round-trip, getUsedTags column, alias
- tests/Integration/SearchTest.php: tests 4-6 for tag subquery, full-text query, count consistency
- Database: getAllPublishedTheses() bypasses 100-row search cap for student index
- search.php: uses getAllPublishedTheses() for étudiantes column; all tests pass
This commit is contained in:
Pontoporeia
2026-03-24 15:38:36 +01:00
parent 92e344b757
commit 372abb5cd6
6 changed files with 84 additions and 7 deletions

View File

@@ -49,6 +49,39 @@ try {
}
}
// Test 5: findOrCreateTag round-trip
echo "Test 5: findOrCreateTag round-trip\n";
$testTag = '__test_tag_' . bin2hex(random_bytes(4));
$id1 = $db->findOrCreateTag($testTag);
$id2 = $db->findOrCreateTag($testTag); // should return same id
if ($id1 && $id1 === $id2) {
echo "✓ PASS: findOrCreateTag returned consistent id=$id1 for '$testTag'\n\n";
// Clean up
$db->deleteTag($id1);
} else {
throw new Exception("findOrCreateTag round-trip failed: id1=$id1, id2=$id2");
}
// Test 6: getUsedTags returns array with 'name' column
echo "Test 6: getUsedTags returns name column\n";
$tags = $db->getUsedTags();
if (is_array($tags) && (empty($tags) || isset($tags[0]['name']))) {
echo "✓ PASS: getUsedTags returned " . count($tags) . " tags with 'name' column\n\n";
} else {
throw new Exception("getUsedTags did not return expected structure: " . json_encode($tags[0] ?? []));
}
// Test 7: backwards-compat alias findOrCreateKeyword
echo "Test 7: findOrCreateKeyword alias\n";
$testTag2 = '__kw_alias_' . bin2hex(random_bytes(4));
$kwId = $db->findOrCreateKeyword($testTag2);
if ($kwId > 0) {
echo "✓ PASS: findOrCreateKeyword alias works, id=$kwId\n\n";
$db->deleteTag($kwId);
} else {
throw new Exception("findOrCreateKeyword alias failed");
}
echo "✅ All database tests passed!\n";
return true;