public function testGroupByInvalidPropertyPathReturnsFlatChoices() { $item1 = new Item(1, 'Foo', 'Group1'); $item2 = new Item(2, 'Bar', 'Group1'); $choiceList = new ModelChoiceList(self::ITEM_CLASS, 'value', array($item1, $item2), null, 'child.that.does.not.exist'); $this->assertEquals(array(1 => $item1, 2 => $item2), $choiceList->getChoices()); }
/** * {@inheritdoc} */ public function getChoices() { $choices = parent::getChoices(); $array = array(); foreach ($choices as $value => $label) { $array[] = array('value' => $value, 'label' => $label); } return $array; }
public function testCustomIdentifier() { $item1 = new Item(1, 'Foo', null, null, 'slug'); $item2 = new Item(2, 'Bar', null, null, 'slug2'); $choiceList = new ModelChoiceList(self::ITEM_CLASS, 'value', array($item1, $item2), null, null, array(), null, 'slug'); $this->assertSame(array('slug' => $item1, 'slug2' => $item2), $choiceList->getChoices()); }