[ '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"; }