mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
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:
@@ -40,6 +40,39 @@ try {
|
||||
throw new Exception("Failed to handle special characters");
|
||||
}
|
||||
|
||||
// Test 4: Tag-filter search using the new EXISTS subquery
|
||||
echo "Test 4: Tag-filter search (thesis_tags subquery)\n";
|
||||
$tagResults = $db->searchTheses(['keyword' => 'urbanisme']);
|
||||
if (is_array($tagResults)) {
|
||||
echo "✓ PASS: Tag search for 'urbanisme' returned " . count($tagResults) . " result(s)\n";
|
||||
foreach ($tagResults as $r) {
|
||||
echo " - " . $r['title'] . " (" . $r['year'] . ")\n";
|
||||
}
|
||||
echo "\n";
|
||||
} else {
|
||||
throw new Exception("Tag search returned non-array");
|
||||
}
|
||||
|
||||
// Test 5: Tag search in full-text query (query touches tag subquery)
|
||||
echo "Test 5: Full-text query includes tag subquery\n";
|
||||
$allResults = $db->searchTheses(['query' => 'narration']);
|
||||
if (is_array($allResults)) {
|
||||
echo "✓ PASS: Query 'narration' returned " . count($allResults) . " result(s)\n\n";
|
||||
} else {
|
||||
throw new Exception("Full-text query with tag subquery failed");
|
||||
}
|
||||
|
||||
// Test 6: countSearchResults matches searchTheses
|
||||
echo "Test 6: countSearchResults consistency\n";
|
||||
$params = ['keyword' => 'urbanisme'];
|
||||
$count = $db->countSearchResults($params);
|
||||
$rows = $db->searchTheses($params, 100);
|
||||
if ($count === count($rows)) {
|
||||
echo "✓ PASS: count=$count matches row count\n\n";
|
||||
} else {
|
||||
throw new Exception("countSearchResults ($count) != searchTheses row count (" . count($rows) . ")");
|
||||
}
|
||||
|
||||
echo "✅ All search tests passed!\n";
|
||||
return true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user