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'));
 }
Esempio n. 2
0
 public function testFieldsCollectionOfEntityConfigModel()
 {
     $entityModel = new EntityConfigModel();
     $this->assertCount(0, $entityModel->getFields());
     $fieldModel1 = new FieldConfigModel('field1', 'string');
     $fieldModel2 = new FieldConfigModel('field2', 'integer');
     $entityModel->addField($fieldModel1);
     $entityModel->addField($fieldModel2);
     $fields = $entityModel->getFields();
     $this->assertCount(2, $fields);
     $this->assertSame($fieldModel1, $fields->first());
     $this->assertSame($fieldModel2, $fields->last());
     $this->assertSame($fieldModel1, $entityModel->getField('field1'));
     $this->assertSame($fieldModel2, $entityModel->getField('field2'));
     $fields = $entityModel->getFields(function (FieldConfigModel $model) {
         return $model->getFieldName() === 'field2';
     });
     $this->assertCount(1, $fields);
     $this->assertSame($fieldModel2, $fields->first());
     $entityModel->setFields(new ArrayCollection([$fieldModel1]));
     $fields = $entityModel->getFields();
     $this->assertCount(1, $fields);
     $this->assertSame($fieldModel1, $fields->first());
 }