diff --git a/WebFiori/Cli/Command.php b/WebFiori/Cli/Command.php index 1ff5939..276f767 100644 --- a/WebFiori/Cli/Command.php +++ b/WebFiori/Cli/Command.php @@ -1445,8 +1445,9 @@ private function getDefaultChoiceHelper(array $choices, int $defaultIndex): ?str } $index++; } + + return null; } - /** * Validate user input and show error message if user input is invalid. * @param string $input diff --git a/tests/WebFiori/Tests/Cli/CLICommandTest.php b/tests/WebFiori/Tests/Cli/CLICommandTest.php index 034c11d..50013d9 100644 --- a/tests/WebFiori/Tests/Cli/CLICommandTest.php +++ b/tests/WebFiori/Tests/Cli/CLICommandTest.php @@ -1736,4 +1736,23 @@ public function testCommandExecutionWrapperMethodEnhanced() { $outputArray = $output->getOutputArray(); $this->assertNotEmpty($outputArray); // TestCommand should produce some output } + + /** + * Test select with multiple invalid inputs then empty input (framework scenario) + * @test + */ + public function testSelectFrameworkScenario() { + $command = new TestCommand('test-cmd'); + $output = new ArrayOutputStream(); + $command->setOutputStream($output); + + // Mimic framework test: empty input, invalid input 'XC', then valid input '0' + $input = new ArrayInputStream(['', 'XC', '0']); + $command->setInputStream($input); + + $choices = ['AR', 'EN']; + $result = $command->select('In which language you would like to update?', $choices); + + $this->assertEquals('AR', $result); + } }