public function test() { $this->assertEquals('test', $this->configField->getFieldName($this->configField->setFieldName('test'))); $this->assertEquals('string', $this->configField->getType($this->configField->setType('string'))); $this->assertEquals('Acme\\Bundle\\DemoBundle\\Entity\\TestAccount', $this->configEntity->getClassName($this->configEntity->setClassName('Acme\\Bundle\\DemoBundle\\Entity\\TestAccount'))); /** test ConfigField set/getEntity */ $this->configField->setEntity($this->configEntity); $this->assertEquals($this->configEntity, $this->configField->getEntity()); /** test ConfigField getOptions */ $this->assertInstanceOf('\\Doctrine\\Common\\Collections\\ArrayCollection', $this->configField->getOptions()); /** test ConfigEntity addField */ $this->configEntity->addField($this->configField); $this->assertEquals($this->configField, $this->configEntity->getField('test')); /** test ConfigEntity setFields */ $this->configEntity->setFields(array($this->configField)); $this->assertEquals(array($this->configField), $this->configEntity->getFields()); /** test ConfigValue */ $this->configValue->setCode('is_extend')->setScope('extend')->setValue(true)->setField($this->configField); $this->assertEquals(array('code' => 'is_extend', 'scope' => 'extend', 'value' => true, 'serializable' => false), $this->configValue->toArray()); /** test Config setValues() */ $this->configEntity->setValues(array($this->configValue)); $this->assertEquals($this->configValue, $this->configEntity->getValue('is_extend', 'extend')); }
public function testFieldConfigModel() { $fieldName = 'testField'; $fieldType = 'integer'; $entityModel = new EntityConfigModel('Test\\TestClass'); $fieldModel = new FieldConfigModel($fieldName, $fieldType); $fieldModel->setEntity($entityModel); $this->assertEmpty($fieldModel->getId()); $this->assertEquals($fieldName, $fieldModel->getFieldName()); $this->assertEquals($fieldType, $fieldModel->getType()); $this->assertSame($entityModel, $fieldModel->getEntity()); $fieldName1 = 'testField'; $fieldType1 = 'integer'; $fieldModel->setFieldName($fieldName1); $fieldModel->setType($fieldType1); $this->assertEquals($fieldName1, $fieldModel->getFieldName()); $this->assertEquals($fieldType1, $fieldModel->getType()); $this->assertCount(0, $fieldModel->getOptions()); $optionSet = new OptionSet(); $fieldModel->setOptions(new ArrayCollection([$optionSet])); $this->assertCount(1, $fieldModel->getOptions()); $this->assertSame($optionSet, $fieldModel->getOptions()->first()); }
/** * Returns default options for the given option set * * @param FieldConfigModel $configFieldModel * @return int[] */ protected function getDefaultOptionIds(FieldConfigModel $configFieldModel) { $defaultOptionIds = []; foreach ($configFieldModel->getOptions()->toArray() as $option) { if ($option->getIsDefault()) { $defaultOptionIds[] = $option->getId(); } } return $defaultOptionIds; }