- Move 45 debug/test files from root to organized scripts/ directories - Secure public/ directory by removing debug files (security improvement) - Create structured scripts organization: • scripts/debug/ (20 files) - Framework debugging tools • scripts/test/ (18 files) - Test and validation scripts • scripts/maintenance/ (5 files) - Maintenance utilities • scripts/dev/ (2 files) - Development tools Security improvements: - Removed all debug/test files from public/ directory - Only production files remain: index.php, health.php Root directory cleanup: - Reduced from 47 to 2 PHP files in root - Only essential production files: console.php, worker.php This improves: ✅ Security (no debug code in public/) ✅ Organization (clear separation of concerns) ✅ Maintainability (easy to find and manage scripts) ✅ Professional structure (clean root directory)
95 lines
3.3 KiB
PHP
95 lines
3.3 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
|
|
// Test TUI navigation functionality
|
|
use App\Framework\Console\Components\TuiState;
|
|
use App\Framework\Console\Components\TuiInputHandler;
|
|
use App\Framework\Console\Components\TuiCommandExecutor;
|
|
use App\Framework\Console\CommandHistory;
|
|
use App\Framework\Console\TuiView;
|
|
use App\Framework\Console\TuiKeyCode;
|
|
|
|
echo "Testing TUI Navigation...\n";
|
|
echo "=========================\n\n";
|
|
|
|
try {
|
|
// Create mock executor
|
|
$mockExecutor = new class implements \App\Framework\Console\Components\TuiCommandExecutor {
|
|
public function executeSelectedCommand(object $command): void {
|
|
echo "Mock: Execute command\n";
|
|
}
|
|
public function executeCommand(string $commandName): void {
|
|
echo "Mock: Execute command: $commandName\n";
|
|
}
|
|
public function validateSelectedCommand(object $command): void {
|
|
echo "Mock: Validate command\n";
|
|
}
|
|
public function validateCommand(string $commandName): void {
|
|
echo "Mock: Validate command: $commandName\n";
|
|
}
|
|
public function showSelectedCommandHelp(object $command): void {
|
|
echo "Mock: Show help\n";
|
|
}
|
|
public function showCommandHelp(string $commandName): void {
|
|
echo "Mock: Show help: $commandName\n";
|
|
}
|
|
public function showAllCommandsHelp(): void {
|
|
echo "Mock: Show all commands help\n";
|
|
}
|
|
public function startInteractiveForm(object $command, \App\Framework\Console\Components\TuiState $state): void {
|
|
echo "Mock: Start form\n";
|
|
}
|
|
public function findCommandObject(string $commandName): ?object {
|
|
return null;
|
|
}
|
|
};
|
|
|
|
$state = new TuiState();
|
|
$history = new CommandHistory();
|
|
$inputHandler = new TuiInputHandler($mockExecutor);
|
|
|
|
// Setup test categories
|
|
$categories = [
|
|
'Database' => [
|
|
'name' => 'Database',
|
|
'description' => 'Database commands',
|
|
'icon' => '🗄️',
|
|
'commands' => []
|
|
],
|
|
'Cache' => [
|
|
'name' => 'Cache',
|
|
'description' => 'Cache commands',
|
|
'icon' => '⚡',
|
|
'commands' => []
|
|
]
|
|
];
|
|
|
|
$state->setCategories($categories);
|
|
$state->setCurrentView(TuiView::CATEGORIES);
|
|
$state->setRunning(true);
|
|
|
|
// Test arrow navigation
|
|
echo "Testing arrow key navigation:\n";
|
|
echo "Initial category: " . $state->getSelectedCategory() . "\n";
|
|
|
|
// Test arrow down
|
|
$inputHandler->handleInput(TuiKeyCode::ARROW_DOWN->value, $state, $history);
|
|
echo "After arrow down: " . $state->getSelectedCategory() . "\n";
|
|
|
|
// Test arrow up
|
|
$inputHandler->handleInput(TuiKeyCode::ARROW_UP->value, $state, $history);
|
|
echo "After arrow up: " . $state->getSelectedCategory() . "\n";
|
|
|
|
// Test bounds checking - try to go below 0
|
|
$inputHandler->handleInput(TuiKeyCode::ARROW_UP->value, $state, $history);
|
|
echo "After arrow up (should stay at 0): " . $state->getSelectedCategory() . "\n";
|
|
|
|
echo "\n✅ TUI Navigation Test PASSED - Arrow key handling works!\n";
|
|
|
|
} catch (\Throwable $e) {
|
|
echo "\n❌ TUI Navigation Test FAILED:\n";
|
|
echo "Error: " . $e->getMessage() . "\n";
|
|
echo "File: " . $e->getFile() . ":" . $e->getLine() . "\n";
|
|
echo "\nStack trace:\n" . $e->getTraceAsString() . "\n";
|
|
} |