public function testInitArrayWithValuePath()
 {
     $this->obj1 = (object) array('name' => 'A', 'id' => 10);
     $this->obj2 = (object) array('name' => 'B', 'id' => 20);
     $this->obj3 = (object) array('name' => 'C', 'id' => 30);
     $this->obj4 = (object) array('name' => 'D', 'id' => 40);
     $this->list = new ObjectChoiceList(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), 'name', array($this->obj2, $this->obj3), null, 'id');
     $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices());
     $this->assertSame(array('10', '20', '30', '40'), $this->list->getValues());
     $this->assertEquals(array(1 => new ChoiceView($this->obj2, '20', 'B'), 2 => new ChoiceView($this->obj3, '30', 'C')), $this->list->getPreferredViews());
     $this->assertEquals(array(0 => new ChoiceView($this->obj1, '10', 'A'), 3 => new ChoiceView($this->obj4, '40', 'D')), $this->list->getRemainingViews());
 }
Пример #2
0
 /**
  * Returns the choice views of the preferred choices as nested array with
  * the choice groups as top-level keys.
  *
  * @return array
  *
  * @see Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface
  */
 public function getPreferredViews()
 {
     if (!$this->loaded) {
         $this->load();
     }
     return parent::getPreferredViews();
 }