/** * @dataProvider provideConvertibleChoices */ public function testConvertChoicesIfNecessary(array $choices, array $converted) { $list = new ArrayKeyChoiceList($choices); $this->assertSame($converted, $list->getChoices()); }
public function testCreateChoiceListWithValueCallback() { $callback = function ($choice) { return ':' . $choice; }; $choiceList = new ArrayKeyChoiceList(array('foo' => 'Foo', 'bar' => 'Bar', 'baz' => 'Baz'), $callback); $this->assertSame(array(':foo', ':bar', ':baz'), $choiceList->getValues()); $this->assertSame(array(':foo' => 'foo', ':bar' => 'bar', ':baz' => 'baz'), $choiceList->getChoices()); $this->assertSame(array(':foo' => 'Foo', ':bar' => 'Bar', ':baz' => 'Baz'), $choiceList->getOriginalKeys()); $this->assertSame(array(1 => 'foo', 2 => 'baz'), $choiceList->getChoicesForValues(array(1 => ':foo', 2 => ':baz'))); $this->assertSame(array(1 => ':foo', 2 => ':baz'), $choiceList->getValuesForChoices(array(1 => 'foo', 2 => 'baz'))); }