本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\Config::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::set方法的具体用法?PHP Config::set怎么用?PHP Config::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Config\Config
的用法示例。
在下文中一共展示了Config::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetEntities
public function testGetEntities()
{
$entityConfig = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface')->disableOriginalConstructor()->getMock();
$entityConfig->expects($this->at(0))->method('get')->with('label')->will($this->returnValue('SomeLabel'));
$this->entityConfigProvider->expects($this->once())->method('hasConfig')->with('SomeClass')->will($this->returnValue(true));
$this->entityConfigProvider->expects($this->once())->method('getConfig')->with('SomeClass')->will($this->returnValue($entityConfig));
$securityConfigId = new EntityConfigId('security', 'SomeClass');
$securityConfig = new Config($securityConfigId);
$securityConfig->set('type', Provider::ACL_SECURITY_TYPE);
$securityConfig->set('permissions', 'All');
$securityConfig->set('group_name', 'SomeGroup');
$securityConfigs = array($securityConfig);
$this->securityConfigProvider->expects($this->any())->method('getConfigs')->will($this->returnValue($securityConfigs));
$this->cache->expects($this->at(0))->method('fetch')->with(Provider::ACL_SECURITY_TYPE)->will($this->returnValue(false));
$this->cache->expects($this->at(2))->method('fetch')->with(Provider::ACL_SECURITY_TYPE)->will($this->returnValue(array('SomeClass' => $this->entity)));
$this->cache->expects($this->once())->method('save')->with(Provider::ACL_SECURITY_TYPE, array('SomeClass' => $this->entity));
$provider = new Provider($this->securityConfigProvider, $this->entityConfigProvider, $this->extendConfigProvider, $this->cache);
// call without cache
$result = $provider->getEntities();
$this->assertCount(1, $result);
$this->assertContainsOnlyInstancesOf('Oro\\Bundle\\SecurityBundle\\Metadata\\EntitySecurityMetadata', $result);
$this->assertEquals(serialize($result), serialize(array($this->entity)));
// call with local cache
$result = $provider->getEntities();
$this->assertCount(1, $result);
$this->assertContainsOnlyInstancesOf('Oro\\Bundle\\SecurityBundle\\Metadata\\EntitySecurityMetadata', $result);
$this->assertEquals(serialize($result), serialize(array($this->entity)));
// call with cache
$provider = new Provider($this->securityConfigProvider, $this->entityConfigProvider, $this->extendConfigProvider, $this->cache);
$result = $provider->getEntities();
$this->assertCount(1, $result);
$this->assertContains($this->entity, $result);
}
示例2: testGetMetadataSetsOrganizationFieldName
public function testGetMetadataSetsOrganizationFieldName()
{
$configProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
$provider = new OwnershipMetadataProvider(array('organization' => 'AcmeBundle\\Entity\\Organization', 'business_unit' => 'AcmeBundle\\Entity\\BusinessUnit', 'user' => 'AcmeBundle\\Entity\\User'), $configProvider, null);
$config = new Config(new EntityConfigId('ownership', 'SomeClass'));
$config->set('owner_type', 'ORGANIZATION');
$config->set('owner_field_name', 'test_field');
$config->set('owner_column_name', 'test_column');
$configProvider->expects($this->once())->method('hasConfig')->with($this->equalTo('SomeClass'))->will($this->returnValue(true));
$configProvider->expects($this->once())->method('getConfig')->with($this->equalTo('SomeClass'))->will($this->returnValue($config));
$this->assertEquals(new OwnershipMetadata('ORGANIZATION', 'test_field', 'test_column', 'test_field', 'test_column'), $provider->getMetadata('SomeClass'));
}
示例3: testFlush
public function testFlush()
{
$container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
$model = new EntityConfigModel(self::ENTITY_CLASS);
$entityConfigId = new EntityConfigId('entity', self::ENTITY_CLASS);
$entityConfig = new Config($entityConfigId);
$entityConfig->set('icon', 'test_icon');
$entityConfig->set('label', 'test_label');
$entityPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['icon' => [], 'label' => ['options' => ['indexed' => true]]]]], $container);
$this->entityConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($entityPropertyConfig));
$testConfigId = new EntityConfigId('test', self::ENTITY_CLASS);
$testConfig = new Config($testConfigId);
$testConfig->set('attr1', 'test_attr1');
$testPropertyConfig = new PropertyConfigContainer(['entity' => ['items' => ['attr1' => []]]], $container);
$this->testConfigProvider->expects($this->once())->method('getPropertyConfig')->will($this->returnValue($testPropertyConfig));
$this->modelManager->expects($this->once())->method('getEntityModel')->with($entityConfigId->getClassName())->will($this->returnValue($model));
$em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
$this->modelManager->expects($this->any())->method('getEntityManager')->will($this->returnValue($em));
$this->setFlushExpectations($em, [$model]);
$this->eventDispatcher->expects($this->at(0))->method('dispatch')->with(Events::PRE_PERSIST_CONFIG, new PersistConfigEvent($entityConfig, $this->configManager));
$this->eventDispatcher->expects($this->at(1))->method('dispatch')->with(Events::PRE_PERSIST_CONFIG, new PersistConfigEvent($testConfig, $this->configManager));
$this->configManager->persist($entityConfig);
$this->configManager->persist($testConfig);
$this->configManager->flush();
$this->assertEquals(['icon' => 'test_icon', 'label' => 'test_label'], $model->toArray('entity'));
$this->assertEquals(['attr1' => 'test_attr1'], $model->toArray('test'));
$this->assertCount(3, $model->getIndexedValues());
$this->assertEquals('entity_config', $model->getIndexedValues()[0]->getScope());
$this->assertEquals('module_name', $model->getIndexedValues()[0]->getCode());
$this->assertEquals('entity_config', $model->getIndexedValues()[1]->getScope());
$this->assertEquals('entity_name', $model->getIndexedValues()[1]->getCode());
$this->assertEquals('entity', $model->getIndexedValues()[2]->getScope());
$this->assertEquals('label', $model->getIndexedValues()[2]->getCode());
}
示例4: testResolve
public function testResolve()
{
$route = new Route('/{activity}/route', [], [], ['group' => ActivityAssociationRouteOptionsResolver::ROUTE_GROUP]);
$this->routeCollection->add('first_route', new Route('/first_route'));
$this->routeCollection->add('override_before', new Route('/events/route'));
$this->routeCollection->add('some_route', new Route('/some_route'));
$this->routeCollection->add('tested_route', $route);
$this->routeCollection->add('override_after', new Route('/emails/route'));
$this->routeCollection->add('last_route', new Route('/last_route'));
$config1 = new Config(new EntityConfigId('grouping', 'Test\\Email'));
$config1->set('groups', ['activity']);
$config2 = new Config(new EntityConfigId('grouping', 'Test\\Call'));
$config2->set('groups', ['test', 'activity']);
$config3 = new Config(new EntityConfigId('grouping', 'Test\\Task'));
$config3->set('groups', ['activity']);
$config4 = new Config(new EntityConfigId('grouping', 'Test\\Message'));
$config5 = new Config(new EntityConfigId('grouping', 'Test\\Event'));
$config5->set('groups', ['activity']);
$this->groupingConfigProvider->expects($this->once())->method('getConfigs')->with(null, false)->willReturn([$config1, $config2, $config3, $config4, $config5]);
$this->entityAliasResolver->expects($this->exactly(4))->method('getPluralAlias')->willReturnMap([['Test\\Email', 'emails'], ['Test\\Call', 'calls'], ['Test\\Task', 'tasks'], ['Test\\Event', 'events']]);
$this->routeOptionsResolver->resolve($route, $this->routeCollectionAccessor);
$this->assertEquals(['activity' => '\\w+'], $route->getRequirements());
$this->routeCollection->sortByPriority();
$this->assertEquals(['first_route', 'some_route', 'override_after', 'tested_route_auto_7', 'tested_route_auto_8', 'override_before', 'tested_route', 'last_route'], array_keys($this->routeCollection->all()));
$this->assertEquals('\\w+', $this->routeCollection->get('tested_route')->getRequirement('activity'));
$this->assertEquals('calls', $this->routeCollection->get('tested_route_auto_7')->getDefault('activity'));
$this->assertEquals('tasks', $this->routeCollection->get('tested_route_auto_8')->getDefault('activity'));
}
示例5: testResolve
public function testResolve()
{
$route = new Route('/{activity}/route', [], [], ['group' => 'activity_association']);
$this->routeCollection->add('first_route', new Route('/first_route'));
$this->routeCollection->add('override1', new Route('/notes/route'));
$this->routeCollection->add('some_route', new Route('/some_route'));
$this->routeCollection->add('tested_route', $route);
$this->routeCollection->add('override2', new Route('/emails/route'));
$this->routeCollection->add('last_route', new Route('/last_route'));
$config1 = new Config(new EntityConfigId('grouping', 'Test\\Email'));
$config1->set('groups', ['activity']);
$config2 = new Config(new EntityConfigId('grouping', 'Test\\Call'));
$config2->set('groups', ['test', 'activity']);
$config3 = new Config(new EntityConfigId('grouping', 'Test\\Message'));
$config4 = new Config(new EntityConfigId('grouping', 'Test\\Note'));
$config4->set('groups', ['activity']);
$this->groupingConfigProvider->expects($this->once())->method('getConfigs')->with(null, false)->willReturn([$config1, $config2, $config3, $config4]);
$this->entityAliasResolver->expects($this->exactly(3))->method('getPluralAlias')->willReturnMap([['Test\\Email', 'emails'], ['Test\\Call', 'calls'], ['Test\\Note', 'notes']]);
$this->routeOptionsResolver->resolve($route, $this->routeCollectionAccessor);
$this->assertEquals(['activity' => 'emails|calls|notes'], $route->getRequirements());
$this->routeCollection->sortByPriority();
$this->assertEquals(['first_route', 'some_route', 'override2', 'tested_route_auto_7', 'override1', 'tested_route', 'last_route'], array_keys($this->routeCollection->all()));
$this->assertEquals('emails|calls|notes', $this->routeCollection->get('tested_route')->getRequirement('activity'));
$this->assertEquals('calls', $this->routeCollection->get('tested_route_auto_7')->getDefault('activity'));
}
示例6: getExtendConfigMock
/**
* @return \PHPUnit_Framework_MockObject_MockObject
*/
protected function getExtendConfigMock()
{
$extendConfigProvider = $this->getMockBuilder('Oro\\Bundle\\EntityConfigBundle\\Provider\\ConfigProvider')->disableOriginalConstructor()->getMock();
$config1 = new Config(new EntityConfigId('extend', self::ENTITY_NAMESPACE . '\\TestEntity1'));
$config2 = new Config(new EntityConfigId('extend', self::ENTITY_NAMESPACE . '\\TestEntity2'));
$config3 = new Config(new EntityConfigId('extend', self::ENTITY_NAMESPACE . '\\TestEntity3'));
$newCustomEntityConfig = new Config(new EntityConfigId('extend', ExtendHelper::ENTITY_NAMESPACE . '\\TestEntity4'));
$newCustomEntityConfig->set('state', ExtendScope::STATE_NEW);
$toBeDeletedCustomEntityConfig = new Config(new EntityConfigId('extend', ExtendHelper::ENTITY_NAMESPACE . '\\TestEntity5'));
$toBeDeletedCustomEntityConfig->set('state', ExtendScope::STATE_DELETE);
$deletedCustomEntityConfig = new Config(new EntityConfigId('extend', ExtendHelper::ENTITY_NAMESPACE . '\\TestEntity6'));
$deletedCustomEntityConfig->set('state', ExtendScope::STATE_ACTIVE);
$deletedCustomEntityConfig->set('is_deleted', true);
$entityConfigs = [$config1, $config2, $config3, $newCustomEntityConfig, $toBeDeletedCustomEntityConfig, $deletedCustomEntityConfig];
$extendConfigProvider->expects($this->once())->method('getConfigs')->will($this->returnValue($entityConfigs));
return $extendConfigProvider;
}
示例7: testIsEntityAuditable
public function testIsEntityAuditable()
{
$config = new Config(new EntityConfigId('dataaudit', self::TEST_ENTITY_REFERENCE));
$config->set('auditable', true);
$this->configProvider->expects($this->once())->method('hasConfig')->with(self::TEST_ENTITY_REFERENCE)->will($this->returnValue(true));
$this->configProvider->expects($this->once())->method('getConfig')->with(self::TEST_ENTITY_REFERENCE)->will($this->returnValue($config));
$this->assertTrue($this->filter->isEntityAuditable(new LoggableClass(), false));
}
示例8: testSupportsForNotActivityEntity
public function testSupportsForNotActivityEntity()
{
$config = new Config(new EntityConfigId('grouping', 'Test\\Entity'));
$config->set('groups', ['another_group']);
$this->groupingConfigProvider->expects($this->once())->method('hasConfig')->with('Test\\Entity')->will($this->returnValue(true));
$this->groupingConfigProvider->expects($this->once())->method('getConfig')->with('Test\\Entity')->will($this->returnValue($config));
$this->assertFalse($this->extension->supports(['class' => 'Test\\Entity']));
}
示例9: testPrePersistEntityConfigWithNoneOwnership
public function testPrePersistEntityConfigWithNoneOwnership()
{
$config = new Config(new EntityConfigId('ownership', 'Test\\Entity1'));
$config->set('owner_type', 'NONE');
$expectedConfig = new Config(new EntityConfigId('ownership', 'Test\\Entity1'));
$this->configManager->expects($this->once())->method('persist')->with($expectedConfig);
$this->configManager->expects($this->once())->method('calculateConfigChangeSet')->with($expectedConfig);
$this->subscriber->prePersistEntityConfig(new PersistConfigEvent($config, $this->configManager));
}
示例10: testIsNoteAssociationEnabled
public function testIsNoteAssociationEnabled()
{
$config = new Config(new EntityConfigId('note', static::TEST_ENTITY_REFERENCE));
$config->set('enabled', true);
$this->noteConfigProvider->expects($this->once())->method('hasConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue(true));
$this->noteConfigProvider->expects($this->once())->method('getConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue($config));
$this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(Note::ENTITY_NAME, ExtendHelper::buildAssociationName(static::TEST_ENTITY_REFERENCE))->will($this->returnValue(true));
$this->assertTrue($this->filter->isNoteAssociationEnabled(new TestEntity(1)));
}
示例11: testIsAttachmentAssociationEnabled
public function testIsAttachmentAssociationEnabled()
{
$config = new Config(new EntityConfigId('attachment', 'stdClass'));
$config->set('enabled', true);
$this->attachmentConfigProvider->expects($this->once())->method('hasConfig')->with('stdClass')->will($this->returnValue(true));
$this->attachmentConfigProvider->expects($this->once())->method('getConfig')->with('stdClass')->will($this->returnValue($config));
$this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(AttachmentScope::ATTACHMENT, ExtendHelper::buildAssociationName('stdClass'))->will($this->returnValue(true));
$this->assertTrue($this->filter->isAttachmentAssociationEnabled(new \stdClass()));
}
示例12: testGetMetadataWithoutCache
public function testGetMetadataWithoutCache()
{
$config = new Config(new EntityConfigId('ownership', 'SomeClass'));
$config->set('frontend_owner_type', 'USER')->set('frontend_owner_field_name', 'test_field')->set('frontend_owner_column_name', 'test_column');
$this->configProvider->expects($this->once())->method('hasConfig')->with('SomeClass')->willReturn(true);
$this->configProvider->expects($this->once())->method('getConfig')->with('SomeClass')->willReturn($config);
$this->cache = null;
$this->assertEquals(new FrontendOwnershipMetadata('USER', 'test_field', 'test_column'), $this->provider->getMetadata('SomeClass'));
}
示例13: testIsNoteAssociationEnabledForEnabledButNotAccessibleAssociationButWithAccessibleFalse
public function testIsNoteAssociationEnabledForEnabledButNotAccessibleAssociationButWithAccessibleFalse()
{
$entityClass = 'Test\\Entity';
$config = new Config(new EntityConfigId('note', $entityClass));
$config->set('enabled', true);
$this->configManager->expects($this->once())->method('hasConfig')->with($entityClass)->willReturn(true);
$this->configManager->expects($this->once())->method('getEntityConfig')->with('note', $entityClass)->willReturn($config);
$this->configManager->expects($this->never())->method('getFieldConfig');
$this->assertTrue($this->noteAssociationHelper->isNoteAssociationEnabled($entityClass, false));
}
示例14: testRenameField
/**
* Test new index created and old deleted when field renamed
*/
public function testRenameField()
{
$entityConfig = new Config(new EntityConfigId('extend', self::ENTITY_CLASS_NAME));
$entityConfig->set('index', ['testField' => ['testField']]);
$this->configProvider->expects($this->once())->method('getConfig')->with(self::ENTITY_CLASS_NAME)->will($this->returnValue($entityConfig));
$event = new RenameFieldEvent(self::ENTITY_CLASS_NAME, 'testField', 'newName', $this->configManager);
$listener = new EntityConfigListener();
$listener->renameField($event);
$this->assertEquals(['newName' => ['testField']], $entityConfig->get('index'));
}
示例15: testIsApplicable
public function testIsApplicable()
{
$config = new Config(new EntityConfigId('comment', static::TEST_ENTITY_REFERENCE));
$config->set('enabled', true);
$this->securityFacade->expects($this->once())->method('isGranted')->with('oro_comment_view')->willReturn(true);
$this->commentConfigProvider->expects($this->once())->method('hasConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue(true));
$this->commentConfigProvider->expects($this->once())->method('getConfig')->with(static::TEST_ENTITY_REFERENCE)->will($this->returnValue($config));
$this->entityConfigProvider->expects($this->once())->method('hasConfig')->with(Comment::ENTITY_NAME, ExtendHelper::buildAssociationName(static::TEST_ENTITY_REFERENCE))->will($this->returnValue(true));
$this->assertTrue($this->filter->isApplicable(new TestEntity()));
}