/** * @group legacy */ public function testCreateViewForLegacyChoiceList() { // legacy ChoiceList instances provide legacy ChoiceView objects $preferred = array(new LegacyChoiceView('x', 'x', 'Preferred')); $other = array(new LegacyChoiceView('y', 'y', 'Other')); $list = $this->getMock('Symfony\\Component\\Form\\Extension\\Core\\ChoiceList\\ChoiceListInterface'); $list->expects($this->once())->method('getPreferredViews')->will($this->returnValue($preferred)); $list->expects($this->once())->method('getRemainingViews')->will($this->returnValue($other)); $view = $this->factory->createView($list); $this->assertEquals(array(new ChoiceView('Other', 'y', 'y')), $view->choices); $this->assertEquals(array(new ChoiceView('Preferred', 'x', 'x')), $view->preferredChoices); }
public function testCreateViewFlatAttrClosureReceivesValue() { $view = $this->factory->createView($this->list, array($this->obj2, $this->obj3), null, null, null, function ($object, $key, $value) { switch ($value) { case '1': return array('attr1' => 'value1'); case '2': return array('attr2' => 'value2'); default: return array(); } }); $this->assertFlatViewWithAttr($view); }