Example #1
0
 public function testGetValuesForChoices()
 {
     $item1 = new Item(1, 'Foo');
     $item2 = new Item(2, 'Bar');
     $choiceList = new ModelChoiceList(self::ITEM_CLASS, 'value', null, null, null, null);
     $this->assertEquals(array(1, 2), $choiceList->getValuesForChoices(array($item1, $item2)));
     $this->assertEquals(array(1, 2), $choiceList->getIndicesForChoices(array($item1, $item2)));
 }
 public function testGetIndicesForNullChoices()
 {
     $item = new Item(1, 'Foo');
     $choiceList = new ModelChoiceList(self::ITEM_CLASS, 'value', array($item));
     $this->assertEquals(array(), $choiceList->getIndicesForChoices(array(null)));
 }
 /**
  * @group legacy
  */
 public function testLegacyGetIndicesForNullChoices()
 {
     $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
     $item = new Item(1, 'Foo');
     $choiceList = new ModelChoiceList(self::ITEM_CLASS, 'value', array($item));
     $this->assertEquals(array(), $choiceList->getIndicesForChoices(array(null)));
 }
 public function testDifferentEqualObjectsAreChoosen()
 {
     $item = new Item(1, 'Foo');
     $choiceList = new ModelChoiceList(self::ITEM_CLASS, 'value', array($item));
     $choosenItem = new Item(1, 'Foo');
     $this->assertEquals(array(1), $choiceList->getIndicesForChoices(array($choosenItem)));
 }