Beispiel #1
0
 /**
  * @param ObjectManager    $manager
  * @param FieldConfigModel $fieldModel
  *
  * @return array
  */
 protected function getLeadSourceOptions(ObjectManager $manager, FieldConfigModel $fieldModel)
 {
     $options = [];
     try {
         $options = $manager->getRepository('OroEntityConfigBundle:OptionSet')->findOptionsByField($fieldModel->getId());
     } catch (\Exception $e) {
     }
     return $options;
 }
 public function testProperties()
 {
     /** test ConfigEntity */
     $this->assertNull($this->configEntity->getClassName());
     $this->assertEmpty($this->configEntity->getId());
     $this->assertNull($this->configEntity->getCreated());
     $this->configEntity->setCreated(new \DateTime('2013-01-01'));
     $this->assertEquals('2013-01-01', $this->configEntity->getCreated()->format('Y-m-d'));
     $this->assertNull($this->configEntity->getUpdated());
     $this->configEntity->setUpdated(new \DateTime('2013-01-01'));
     $this->assertEquals('2013-01-01', $this->configEntity->getUpdated()->format('Y-m-d'));
     /** test ConfigEntity prePersist */
     $this->configEntity->prePersist();
     $currentDate = new \DateTime('now', new \DateTimeZone('UTC'));
     $this->assertEquals($currentDate->format('Y-m-d'), $this->configEntity->getCreated()->format('Y-m-d'));
     /** test ConfigEntity preUpdate */
     $this->configEntity->preUpdate();
     $currentDate = new \DateTime('now', new \DateTimeZone('UTC'));
     $this->assertEquals($currentDate->format('Y-m-d'), $this->configEntity->getUpdated()->format('Y-m-d'));
     /** test ConfigField */
     $this->assertEmpty($this->configField->getId());
     $this->configField->setMode(ConfigModelManager::MODE_READONLY);
     $this->assertEquals(ConfigModelManager::MODE_READONLY, $this->configField->getMode());
     /** test ConfigValue */
     $this->assertEmpty($this->configValue->getId());
     $this->assertEmpty($this->configValue->getScope());
     $this->assertEmpty($this->configValue->getCode());
     $this->assertEmpty($this->configValue->getValue());
     $this->assertEmpty($this->configValue->getField());
     $this->assertFalse($this->configValue->getSerializable());
     $this->configValue->setSerializable(true);
     $this->assertTrue($this->configValue->getSerializable());
     $this->assertEmpty($this->configValue->getEntity());
     $this->configValue->setEntity($this->configEntity);
     $this->assertEquals($this->configEntity, $this->configValue->getEntity());
 }
Beispiel #3
0
 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());
 }
Beispiel #4
0
 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());
 }
Beispiel #5
0
 /**
  * Returns already set options for the given option set and entity
  *
  * @param FieldConfigModel $configFieldModel
  * @param int              $entityId
  * @return int[]
  */
 protected function getSavedOptionIds(FieldConfigModel $configFieldModel, $entityId)
 {
     $savedOptionIds = $this->relations->findByFieldId($configFieldModel->getId(), $entityId);
     array_walk($savedOptionIds, function (&$item) {
         $item = $item->getOption()->getId();
     });
     return $savedOptionIds;
 }