public function doTestPreSetDataForNewEntityWithMultiEnum(AbstractType $type) { $enumValueClassName = 'Test\\EnumValue'; $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'); $formConfig = $this->getMock('Symfony\\Component\\Form\\FormConfigInterface'); $formConfig->expects($this->exactly(2))->method('getOption')->will($this->returnValueMap([['class', null, $enumValueClassName], ['multiple', null, true]])); $form->expects($this->once())->method('getConfig')->will($this->returnValue($formConfig)); $event = $this->getFormEventMock(new TestEntity(), $form); $this->setExpectationsForLoadDefaultEnumValues($enumValueClassName, ['val1', 'val2']); $event->expects($this->once())->method('setData')->with(['val1', 'val2']); $type->preSetData($event); }
public function doTestPreSetDataForNewEntityWithMultiEnum(AbstractType $type) { $enumValueClassName = 'Test\\EnumValue'; $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface'); $formConfig = $this->expectFormWillReturnFormConfig($form); $this->expectFormConfigWillReturnOptions($formConfig, [['class', null, $enumValueClassName], ['multiple', null, true]]); $parentForm = $this->expectFormWillReturnParentForm($form); $parentFormConfig = $this->expectFormWillReturnFormConfig($parentForm); $this->expectFormConfigWillReturnOptions($parentFormConfig, [['data_class', null, 'TestEntity']]); $data = new TestEntity(); $data->setValue(new ArrayCollection()); $this->expectFormWillReturnData($parentForm, $data); // name of property TestEntity::$value $form->expects($this->once())->method('getPropertyPath')->will($this->returnValue('value')); $event = $this->getFormEventMock2($form); $this->setExpectationsForLoadDefaultEnumValues($enumValueClassName, ['val1', 'val2']); $event->expects($this->once())->method('setData')->with(['val1', 'val2']); $type->preSetData($event); }