本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\Config类的典型用法代码示例。如果您正苦于以下问题:PHP Config类的具体用法?PHP Config怎么用?PHP Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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'));
}
示例2: 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'));
}
示例3: 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);
}
示例4: getEntityConfig
/**
* @param string $className
* @param mixed $values
*
* @return ConfigInterface
*/
protected function getEntityConfig($className, $values)
{
$configId = new EntityConfigId('extend', $className);
$config = new Config($configId);
$config->setValues($values);
return $config;
}
示例5: 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());
}
示例6: 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']));
}
示例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: 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)));
}
示例9: 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()));
}
示例10: testConfigHas
public function testConfigHas()
{
$config = new Config(new EntityConfigId('test', 'Entity1'), ['attr' => 'val', 'null_attr' => null]);
self::assertBenchmark(__METHOD__, 0.05, function () use($config) {
$config->has('attr');
$config->has('null_attr');
$config->has('undefined_attr');
});
}
示例11: 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'));
}
示例12: prepareConfigProvider
protected function prepareConfigProvider(array $configValues, $className)
{
/** @var \PHPUnit_Framework_MockObject_MockObject|ConfigIdInterface $configId */
$configId = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\Id\\ConfigIdInterface');
$entityConfig = new Config($configId);
$entityConfig->setValues($configValues);
$this->configProvider->expects($this->once())->method('hasConfig')->with($this->equalTo($className))->will($this->returnValue(true));
$this->configProvider->expects($this->once())->method('getConfig')->with($this->equalTo($className))->will($this->returnValue($entityConfig));
}
示例13: 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));
}
示例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()));
}