mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-07 03:29:19 +02:00
Phase 1: Consolidate shared infrastructure - Create shared/ directory for common code - Consolidate Database.php from front-backend and formulaire into unified shared/Database.php - Smart path detection for test.db vs posterg.db - Secure search with wildcard escaping and input validation - Support both singleton and direct instantiation patterns - Full CRUD methods for admin functionality - Move RateLimit.php to shared/ (30 requests/min) - Update all require paths across apps to use shared/ Phase 2: Reorganize directory structure - Rename front-backend/ → apps/public/ - Rename formulaire/ → apps/admin/ - Rename db/ → database/ - Update all file paths for new structure - Create root .gitignore excluding databases, cache, logs Implement secure search feature - Add apps/public/search.php with full-text search across theses - Search filters: query, year, orientation, AP program, keywords - Security features: - SQL injection prevention (prepared statements) - Wildcard injection prevention (escape % and _) - Input validation (max 200 chars, year range 1900-2100) - Rate limiting (30 req/min per IP) - Pagination limited to 100 results/page - XSS protection (htmlspecialchars on output) Add comprehensive test suite - Create apps/public/tests/ with proper structure - tests/Integration/SearchTest.php - 12 search scenarios - tests/Security/SecurityTest.php - vulnerability testing - tests/Unit/RateLimitTest.php - rate limit behavior - Create database/fixtures/CreateTestDatabase.php - Add apps/public/run-tests.php test runner - All tests passing (4/4 suites) Update deployment configuration - Rename justfile 'sync' recipe to 'deploy' - Create deploy group with separate deploy-public and deploy-admin - Add test-deploy recipe for test database - Exclude *.db, tests/, cache/, *.md from production deploy - Deploy shared/ to both public and admin locations Stats: +4482 insertions, -654 deletions across 72 files
86 lines
2.9 KiB
PHP
Executable File
86 lines
2.9 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
/**
|
|
* Simple test runner
|
|
* Runs all tests in the tests/ directory
|
|
*/
|
|
|
|
echo "╔════════════════════════════════════════════╗\n";
|
|
echo "║ Running Front-Backend Tests ║\n";
|
|
echo "╚════════════════════════════════════════════╝\n\n";
|
|
|
|
$testFiles = [
|
|
['name' => 'Fixtures', 'path' => __DIR__ . '/../../database/fixtures/CreateTestDatabase.php'],
|
|
['name' => 'Integration', 'path' => __DIR__ . '/tests/Integration/SearchTest.php'],
|
|
['name' => 'Security', 'path' => __DIR__ . '/tests/Security/SecurityTest.php'],
|
|
['name' => 'Unit', 'path' => __DIR__ . '/tests/Unit/RateLimitTest.php'],
|
|
];
|
|
|
|
$totalTests = 0;
|
|
$passedTests = 0;
|
|
$failedTests = 0;
|
|
|
|
foreach ($testFiles as $test) {
|
|
echo "┌─────────────────────────────────────────┐\n";
|
|
echo "│ Test Suite: " . str_pad($test['name'], 27) . "│\n";
|
|
echo "└─────────────────────────────────────────┘\n\n";
|
|
|
|
$totalTests++;
|
|
$path = $test['path'];
|
|
$file = basename($path);
|
|
|
|
if (!file_exists($path)) {
|
|
echo "⚠️ SKIP: $file (not found at $path)\n\n";
|
|
continue;
|
|
}
|
|
|
|
echo "Running: $file\n";
|
|
echo str_repeat("─", 50) . "\n";
|
|
|
|
ob_start();
|
|
$exitCode = 0;
|
|
|
|
try {
|
|
include $path;
|
|
} catch (Exception $e) {
|
|
echo "❌ ERROR: " . $e->getMessage() . "\n";
|
|
$exitCode = 1;
|
|
}
|
|
|
|
$output = ob_get_clean();
|
|
|
|
if ($exitCode === 0 && (
|
|
strpos($output, '❌') !== false ||
|
|
strpos($output, 'FAIL') !== false ||
|
|
strpos($output, 'Error:') !== false
|
|
)) {
|
|
$exitCode = 1;
|
|
}
|
|
|
|
echo $output;
|
|
|
|
if ($exitCode === 0) {
|
|
echo "\n✅ PASSED\n\n";
|
|
$passedTests++;
|
|
} else {
|
|
echo "\n❌ FAILED\n\n";
|
|
$failedTests++;
|
|
}
|
|
}
|
|
|
|
echo "╔════════════════════════════════════════════╗\n";
|
|
echo "║ Test Summary ║\n";
|
|
echo "╠════════════════════════════════════════════╣\n";
|
|
echo "║ Total: " . str_pad($totalTests, 35) . "║\n";
|
|
echo "║ Passed: " . str_pad($passedTests . " ✅", 36) . "║\n";
|
|
echo "║ Failed: " . str_pad($failedTests . ($failedTests > 0 ? " ❌" : ""), 36) . "║\n";
|
|
echo "╚════════════════════════════════════════════╝\n\n";
|
|
|
|
if ($failedTests > 0) {
|
|
echo "❌ Some tests failed!\n";
|
|
exit(1);
|
|
} else {
|
|
echo "✅ All tests passed!\n";
|
|
exit(0);
|
|
}
|