| Server IP : 65.108.144.40 / Your IP : 216.73.217.165 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 User : dev ( 1000) PHP Version : 8.2.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/project-slim/tests/ |
Upload File : |
<?php
/**
* Comprehensive Test Runner for Slim Framework API
*
* This script runs all available tests in the tests directory
* and provides a comprehensive summary of validation system functionality.
*/
echo "๐งช SLIM FRAMEWORK API - COMPREHENSIVE TEST RUNNER\n";
echo "=" . str_repeat("=", 60) . "\n\n";
$testsDir = __DIR__;
$projectRoot = dirname(__DIR__);
echo "๐ Tests Directory: {$testsDir}\n";
echo "๐ Project Root: {$projectRoot}\n\n";
// Available test files
$testFiles = [
'test_validation_direct.php' => [
'name' => 'Direct Validation Tests',
'description' => 'Tests core validation functionality without API dependencies',
'category' => 'Unit Tests'
],
'test_multi_validation_errors.php' => [
'name' => 'Multi-Error Validation Tests',
'description' => 'Tests collection of multiple validation errors at once',
'category' => 'Integration Tests'
],
'test_connection.php' => [
'name' => 'Database Connection Tests',
'description' => 'Tests database connectivity and basic operations',
'category' => 'Infrastructure Tests'
],
'test_schema.php' => [
'name' => 'Database Schema Tests',
'description' => 'Tests database schema and table structure',
'category' => 'Infrastructure Tests'
],
'test_api.php' => [
'name' => 'API Endpoint Tests',
'description' => 'Tests API endpoints functionality',
'category' => 'API Tests'
],
'debug_login.php' => [
'name' => 'Login Debug Tests',
'description' => 'Debug and troubleshoot login functionality',
'category' => 'Debug Tests'
]
];
// Check which test files actually exist
$availableTests = [];
foreach ($testFiles as $filename => $info) {
$filepath = $testsDir . '/' . $filename;
if (file_exists($filepath)) {
$availableTests[$filename] = $info;
$availableTests[$filename]['filepath'] = $filepath;
}
}
echo "๐ AVAILABLE TEST CATEGORIES:\n";
echo "-" . str_repeat("-", 40) . "\n";
$categories = [];
foreach ($availableTests as $filename => $info) {
$categories[$info['category']][] = $filename;
}
foreach ($categories as $category => $files) {
echo "โข {$category}: " . count($files) . " test(s)\n";
}
echo "\n๐ DETAILED TEST INVENTORY:\n";
echo "-" . str_repeat("-", 40) . "\n";
foreach ($availableTests as $filename => $info) {
echo "โ
{$info['name']}\n";
echo " ๐ File: {$filename}\n";
echo " ๐ Description: {$info['description']}\n";
echo " ๐ท๏ธ Category: {$info['category']}\n";
echo "\n";
}
echo "๐ TEST EXECUTION OPTIONS:\n";
echo "-" . str_repeat("-", 30) . "\n";
echo "1. Run all validation tests (recommended)\n";
echo "2. Run individual test by number\n";
echo "3. Run tests by category\n";
echo "4. Show test file contents\n";
echo "5. Exit\n\n";
// Interactive menu
while (true) {
echo "๐ Select an option (1-5): ";
$choice = trim(fgets(STDIN));
switch ($choice) {
case '1':
runAllValidationTests($availableTests);
break;
case '2':
runIndividualTest($availableTests);
break;
case '3':
runTestsByCategory($categories, $availableTests);
break;
case '4':
showTestContents($availableTests);
break;
case '5':
echo "๐ Goodbye!\n";
exit(0);
default:
echo "โ Invalid choice. Please select 1-5.\n";
}
echo "\n" . str_repeat("-", 50) . "\n";
}
function runAllValidationTests($availableTests) {
echo "\n๐งช RUNNING ALL VALIDATION TESTS\n";
echo "=" . str_repeat("=", 40) . "\n\n";
$validationTests = [
'test_validation_direct.php',
'test_multi_validation_errors.php'
];
foreach ($validationTests as $testFile) {
if (isset($availableTests[$testFile])) {
echo "โถ๏ธ Running: {$availableTests[$testFile]['name']}\n";
echo "-" . str_repeat("-", 50) . "\n";
$output = runTestFile($availableTests[$testFile]['filepath']);
echo $output . "\n";
echo "โ
Completed: {$testFile}\n\n";
}
}
}
function runIndividualTest($availableTests) {
echo "\n๐ SELECT INDIVIDUAL TEST:\n";
echo "-" . str_repeat("-", 30) . "\n";
$index = 1;
$testIndex = [];
foreach ($availableTests as $filename => $info) {
echo "{$index}. {$info['name']} ({$filename})\n";
$testIndex[$index] = $filename;
$index++;
}
echo "\n๐ Select test number (1-" . (count($availableTests)) . "): ";
$choice = trim(fgets(STDIN));
if (isset($testIndex[$choice])) {
$filename = $testIndex[$choice];
$info = $availableTests[$filename];
echo "\nโถ๏ธ Running: {$info['name']}\n";
echo "-" . str_repeat("-", 50) . "\n";
$output = runTestFile($info['filepath']);
echo $output . "\n";
echo "โ
Completed: {$filename}\n";
} else {
echo "โ Invalid test number.\n";
}
}
function runTestsByCategory($categories, $availableTests) {
echo "\n๐ SELECT TEST CATEGORY:\n";
echo "-" . str_repeat("-", 25) . "\n";
$index = 1;
$categoryIndex = [];
foreach ($categories as $category => $files) {
echo "{$index}. {$category} (" . count($files) . " tests)\n";
$categoryIndex[$index] = $category;
$index++;
}
echo "\n๐ Select category number (1-" . (count($categories)) . "): ";
$choice = trim(fgets(STDIN));
if (isset($categoryIndex[$choice])) {
$category = $categoryIndex[$choice];
$files = $categories[$category];
echo "\nโถ๏ธ Running {$category} Tests:\n";
echo "=" . str_repeat("=", 40) . "\n\n";
foreach ($files as $filename) {
$info = $availableTests[$filename];
echo "โถ๏ธ Running: {$info['name']}\n";
echo "-" . str_repeat("-", 50) . "\n";
$output = runTestFile($info['filepath']);
echo $output . "\n";
echo "โ
Completed: {$filename}\n\n";
}
} else {
echo "โ Invalid category number.\n";
}
}
function showTestContents($availableTests) {
echo "\n๐ SELECT TEST TO VIEW:\n";
echo "-" . str_repeat("-", 25) . "\n";
$index = 1;
$testIndex = [];
foreach ($availableTests as $filename => $info) {
echo "{$index}. {$info['name']} ({$filename})\n";
$testIndex[$index] = $filename;
$index++;
}
echo "\n๐ Select test number to view (1-" . (count($availableTests)) . "): ";
$choice = trim(fgets(STDIN));
if (isset($testIndex[$choice])) {
$filename = $testIndex[$choice];
$info = $availableTests[$filename];
echo "\n๐ VIEWING: {$info['name']}\n";
echo "=" . str_repeat("=", 50) . "\n";
echo "File: {$filename}\n";
echo "Description: {$info['description']}\n";
echo "-" . str_repeat("-", 50) . "\n\n";
$content = file_get_contents($info['filepath']);
$lines = explode("\n", $content);
// Show first 50 lines
$showLines = min(50, count($lines));
for ($i = 0; $i < $showLines; $i++) {
printf("%3d: %s\n", $i + 1, $lines[$i]);
}
if (count($lines) > 50) {
echo "\n... [" . (count($lines) - 50) . " more lines] ...\n";
echo "\n๐ View full file? (y/n): ";
$viewFull = trim(fgets(STDIN));
if (strtolower($viewFull) === 'y') {
for ($i = 50; $i < count($lines); $i++) {
printf("%3d: %s\n", $i + 1, $lines[$i]);
}
}
}
} else {
echo "โ Invalid test number.\n";
}
}
function runTestFile($filepath) {
ob_start();
try {
// Change to the test directory
$originalDir = getcwd();
chdir(dirname($filepath));
// Include and run the test
include $filepath;
// Restore original directory
chdir($originalDir);
} catch (Exception $e) {
echo "โ ERROR: " . $e->getMessage() . "\n";
echo "๐ File: " . $e->getFile() . "\n";
echo "๐ Line: " . $e->getLine() . "\n";
} catch (Error $e) {
echo "โ FATAL ERROR: " . $e->getMessage() . "\n";
echo "๐ File: " . $e->getFile() . "\n";
echo "๐ Line: " . $e->getLine() . "\n";
}
$output = ob_get_clean();
return $output;
}
echo "\n๐ก TIP: Run validation tests first to verify the system is working correctly!\n";
echo "๐ง All test files are organized in the /tests directory for easy maintenance.\n";