return ['0', '1', '2', '3', '4', '5', '6', '7', '8'
];
} public function testCreateChoiceListWithValueCallback() { $callback =
fn ($choice) => ':'.
$choice;
$choiceList =
new ArrayChoiceList([2 => 'foo', 7 => 'bar', 10 => 'baz'
],
$callback);
$this->
assertSame([':foo', ':bar', ':baz'
],
$choiceList->
getValues());
$this->
assertSame([':foo' => 'foo', ':bar' => 'bar', ':baz' => 'baz'
],
$choiceList->
getChoices());
$this->
assertSame([':foo' => 2, ':bar' => 7, ':baz' => 10
],
$choiceList->
getOriginalKeys());
$this->
assertSame([1 => 'foo', 2 => 'baz'
],
$choiceList->
getChoicesForValues([1 => ':foo', 2 => ':baz'
]));
$this->
assertSame([1 => ':foo', 2 => ':baz'
],
$choiceList->
getValuesForChoices([1 => 'foo', 2 => 'baz'
]));
} public function testCreateChoiceListWithoutValueCallbackAndDuplicateFreeToStringChoices() { $choiceList =
new ArrayChoiceList([2 => 'foo', 7 => 'bar', 10 => 123
]);
$this->
assertSame(['foo', 'bar', '123'
],
$choiceList->
getValues());
$this->
assertSame(['foo' => 'foo', 'bar' => 'bar', '123' => 123
],
$choiceList->
getChoices());
$this->
assertSame(['foo' => 2, 'bar' => 7, '123' => 10
],
$choiceList->
getOriginalKeys());