Пример #1
0
 public function testEntityConfigModel()
 {
     $className = 'Test\\TestClass';
     $entityModel = new EntityConfigModel($className);
     $this->assertEmpty($entityModel->getId());
     $this->assertEquals($className, $entityModel->getClassName());
     $className1 = 'Test\\TestClass1';
     $entityModel->setClassName($className1);
     $this->assertEquals($className1, $entityModel->getClassName());
 }
Пример #2
0
 public function testType()
 {
     $formData = array('className' => 'NewEntityClassName');
     $form = $this->factory->create($this->type);
     $form->submit($formData);
     $object = new EntityConfigModel();
     $object->setClassName('NewEntityClassName');
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
 }
Пример #3
0
 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'));
 }
 /**
  * @dataProvider customEntityDataProvider
  */
 public function testGetEntityAliasForCustomEntity($entityClass, $expectedAlias)
 {
     $entityConfigModel = new EntityConfigModel();
     $entityConfigModel->setClassName($entityClass);
     $entityConfigModel->setMode(ConfigModelManager::MODE_DEFAULT);
     $enumConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
     $enumConfig = new Config(new EntityConfigId('enum', $entityClass));
     $groupingConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
     $groupingConfig = new Config(new EntityConfigId('grouping', $entityClass));
     $this->configManager->expects($this->once())->method('getConfigEntityModel')->with($entityClass)->willReturn($entityConfigModel);
     $this->configManager->expects($this->exactly(2))->method('getProvider')->willReturnMap([['enum', $enumConfigProvider], ['grouping', $groupingConfigProvider]]);
     $enumConfigProvider->expects($this->once())->method('getConfig')->with($entityClass)->willReturn($enumConfig);
     $groupingConfigProvider->expects($this->once())->method('getConfig')->with($entityClass)->willReturn($groupingConfig);
     $result = $this->entityAliasProvider->getEntityAlias($entityClass);
     $this->assertEntityAlias($expectedAlias, $result);
 }