mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 11:09:18 +02:00
feat: prevent duplicate TFE submissions with logging and user feedback
- Add DuplicateThesisException (typed, carries existing thesis metadata) - Add Database::findDuplicateThesis(): matches on year + author + normalised title (exact, prefix, Levenshtein ≤10% of longer string) - ThesisCreateController::submit() runs duplicate check before any DB write and throws DuplicateThesisException on match - AppLogger::logDuplicate() writes status=duplicate entries to the JSON-lines log for audit purposes - App::flash/consumeFlash extended to support 'warning' flash type - admin/actions/formulaire.php: catches DuplicateThesisException, logs it, flashes an HTML warning toast with a clickable link to the existing thesis, and repopulates the form fields - partage/index.php: same catch block; surfaces a plain-text flash-warning banner on the student form with identifier, title, and year of the match; form is repopulated via session - toast.php: renders toast--warning variant - admin.css: .toast--warning + link colour rules - form.css: .flash-warning style for the partage form
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* XAMXAM Test Runner
|
||||
* Runs all tests in the tests/ directory
|
||||
@@ -23,7 +24,7 @@ $skippedTests = 0;
|
||||
|
||||
foreach ($testFiles as $test) {
|
||||
echo "┌─────────────────────────────────────────┐\n";
|
||||
echo "│ " . str_pad($test['name'], 41) . "│\n";
|
||||
echo '│ ' . str_pad($test['name'], 41) . "│\n";
|
||||
echo "└─────────────────────────────────────────┘\n\n";
|
||||
|
||||
$totalTests++;
|
||||
@@ -42,17 +43,17 @@ foreach ($testFiles as $test) {
|
||||
|
||||
try {
|
||||
$testResult = include $path;
|
||||
|
||||
|
||||
// Check if test returned false or had error indicators in output
|
||||
$output = ob_get_contents();
|
||||
if ($testResult === false ||
|
||||
if ($testResult === false ||
|
||||
strpos($output, '❌') !== false ||
|
||||
strpos($output, 'FAIL:') !== false) {
|
||||
$exitCode = 1;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$exitCode = 1;
|
||||
echo "❌ EXCEPTION: " . $e->getMessage() . "\n";
|
||||
echo '❌ EXCEPTION: ' . $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
$output = ob_get_clean();
|
||||
@@ -70,11 +71,11 @@ foreach ($testFiles as $test) {
|
||||
echo "╔════════════════════════════════════════════╗\n";
|
||||
echo "║ Test Summary ║\n";
|
||||
echo "╠════════════════════════════════════════════╣\n";
|
||||
echo "║ Total: " . str_pad($totalTests, 34) . "║\n";
|
||||
echo "║ Passed: " . str_pad($passedTests . " ✅", 35) . "║\n";
|
||||
echo "║ Failed: " . str_pad($failedTests . ($failedTests > 0 ? " ❌" : ""), 35) . "║\n";
|
||||
echo '║ Total: ' . str_pad($totalTests, 34) . "║\n";
|
||||
echo '║ Passed: ' . str_pad($passedTests . ' ✅', 35) . "║\n";
|
||||
echo '║ Failed: ' . str_pad($failedTests . ($failedTests > 0 ? ' ❌' : ''), 35) . "║\n";
|
||||
if ($skippedTests > 0) {
|
||||
echo "║ Skipped: " . str_pad($skippedTests . " ⚠️", 36) . "║\n";
|
||||
echo '║ Skipped: ' . str_pad($skippedTests . ' ⚠️', 36) . "║\n";
|
||||
}
|
||||
echo "╚════════════════════════════════════════════╝\n\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user