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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public function render(Console $console): null|int|UnitEnum|string
return true;
}

if (! $this->options->isList() && $answer === (string) $option->key) {
return true;
}

if ($this->options->getOptions()->isList() && $answer === (string) $index) {
return true;
}
Expand All @@ -75,7 +79,9 @@ public function render(Console $console): null|int|UnitEnum|string
});

if ($selectedOption !== null) {
return $selectedOption->value;
return $this->options->isList()
? $selectedOption->value
: $selectedOption->key;
}

return $this->render($console);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function test_assoc_submit_key(): void
$console->writeln("picked {$answer}");
})
->submit(1)
->assertContains('picked B');
->assertContains('picked b');
}

public function test_assoc_submit_value(): void
Expand All @@ -73,7 +73,7 @@ public function test_assoc_submit_value(): void
$console->writeln("picked {$answer}");
})
->submit('B')
->assertContains('picked B');
->assertContains('picked b');
}

public function test_enum_submit_value(): void
Expand Down
Loading