Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion WebFiori/Cli/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/WebFiori/Tests/Cli/CLICommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Loading