403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/project-slim/tests/run_tests.php
<?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";

Youez - 2016 - github.com/yon3zu
LinuXploit