本文整理汇总了PHP中Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration::create方法的典型用法代码示例。如果您正苦于以下问题:PHP DatagridConfiguration::create方法的具体用法?PHP DatagridConfiguration::create怎么用?PHP DatagridConfiguration::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\DataGridBundle\Datagrid\Common\DatagridConfiguration
的用法示例。
在下文中一共展示了DatagridConfiguration::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testVisitMetadata
public function testVisitMetadata()
{
$config = DatagridConfiguration::create(['options' => ['mode' => ModeExtension::MODE_CLIENT]]);
$metadata = MetadataObject::create([]);
$this->extension->visitMetadata($config, $metadata);
$this->assertEquals(ModeExtension::MODE_CLIENT, $metadata->offsetGetByPath('mode'));
}
示例2: setUp
protected function setUp()
{
$this->acceptor = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Extension\\Acceptor')->disableOriginalConstructor()->getMock();
$this->parameters = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datagrid\\ParameterBag');
$this->grid = new Datagrid(self::TEST_NAME, DatagridConfiguration::create([]), $this->parameters);
$this->grid->setAcceptor($this->acceptor);
}
示例3: testVisitResult
public function testVisitResult()
{
$result = ResultsObject::create([]);
$this->extension->visitResult(DatagridConfiguration::create([]), $result);
$this->assertArrayHasKey('metadata', $result);
$this->assertInternalType('array', $result['metadata']);
}
示例4: getDatagrid
/**
* @param string $entityName
* @param bool $isAlreadyConfigured
*
* @return Datagrid
*/
protected function getDatagrid($entityName, $isAlreadyConfigured)
{
$config = DatagridConfiguration::create(['source' => ['query' => ['from' => [['table' => $entityName]]]]]);
if ($isAlreadyConfigured) {
$config['mass_actions'] = ['mass_update' => ['action settings']];
}
return new Datagrid('test', $config, new ParameterBag());
}
示例5: testSetConfig
/**
* Test methods getConfig, setConfig
*/
public function testSetConfig()
{
$this->assertSame($this->config, $this->acceptor->getConfig());
$newConfig = DatagridConfiguration::create([]);
$this->acceptor->setConfig($newConfig);
$this->assertSame($newConfig, $this->acceptor->getConfig());
$this->assertNotSame($this->config, $this->acceptor->getConfig());
}
示例6: testOnBuildAfterException
/**
* @expectedException \Oro\Bundle\DataGridBundle\Exception\LogicException
* @expectedExceptionMessage cellSelection options `columnName`, `selector` are required
*/
public function testOnBuildAfterException()
{
$config = DatagridConfiguration::create(['options' => ['cellSelection' => ['dataField' => 'id']]]);
$this->datagrid->expects($this->once())->method('getDatasource')->will($this->returnValue($this->datasource));
$this->datagrid->expects($this->once())->method('getConfig')->will($this->returnValue($config));
$this->event->expects($this->once())->method('getDatagrid')->will($this->returnValue($this->datagrid));
$this->listener->onBuildAfter($this->event);
}
示例7: testDispatchGridConfigEvent
/**
* @dataProvider eventDataProvider
*
* @param array $config
* @param array $expectedEvents
*/
public function testDispatchGridConfigEvent(array $config, array $expectedEvents)
{
$config = DatagridConfiguration::create($config);
foreach ($expectedEvents as $k => $event) {
$this->realDispatcherMock->expects($this->at($k))->method('dispatch')->with($event);
}
$event = new GridConfigEvent($config);
$this->dispatcher->dispatch(self::TEST_EVENT_NAME, $event);
}
示例8: testOnBuildBeforeAccountGroups
public function testOnBuildBeforeAccountGroups()
{
/** @var \PHPUnit_Framework_MockObject_MockObject|DatagridInterface $datagrid */
$datagrid = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datagrid\\DatagridInterface');
$config = DatagridConfiguration::create([]);
$event = new BuildBefore($datagrid, $config);
$this->listener->onBuildBeforeAccountGroups($event);
$this->assertEquals($this->expectedTemplateForAccountGroup, $config->toArray());
}
示例9: testSetColumnOptions
public function testSetColumnOptions()
{
$container = new ContainerBuilder();
$datagridGuesser = new DatagridGuesser($container, []);
$config = DatagridConfiguration::create([]);
$columnOptions = [DatagridGuesser::FORMATTER => ['formatter_prop' => 'test'], DatagridGuesser::SORTER => ['sorter_prop' => 'test'], DatagridGuesser::FILTER => ['filter_prop' => 'test']];
$datagridGuesser->setColumnOptions($config, 'testColumn', $columnOptions);
$this->assertEquals(['columns' => ['testColumn' => ['formatter_prop' => 'test']], 'sorters' => ['columns' => ['testColumn' => ['sorter_prop' => 'test']]], 'filters' => ['columns' => ['testColumn' => ['filter_prop' => 'test']]]], $config->toArray());
}
示例10: testOnPreBuildNotApplicable
public function testOnPreBuildNotApplicable()
{
$gridName = ConfigurationProvider::GRID_PREFIX;
$config = DatagridConfiguration::create([]);
$event = new PreBuild($config, new ParameterBag([]));
$this->marketingListHelper->expects($this->any())->method('getMarketingListIdByGridName')->with($this->equalTo($gridName));
$this->groupByHelper->expects($this->never())->method('getGroupByFields');
$this->listener->onPreBuild($event);
}
示例11: testOnPreBuild
/**
* @param string $gridName
* @param array $parameters
* @param array $select
* @param string $groupBy
* @param string $expected
*
* @dataProvider preBuildDataProvider
*/
public function testOnPreBuild($gridName, array $parameters, array $select, $groupBy, $expected)
{
$config = DatagridConfiguration::create(['name' => $gridName, 'source' => ['query' => ['select' => $select, 'groupBy' => $groupBy]]]);
$event = new PreBuild($config, new ParameterBag($parameters));
$this->segmentHelper->expects($this->any())->method('getSegmentIdByGridName')->with($this->equalTo($gridName))->will($this->returnValue(true));
$this->segmentHelper->expects($this->any())->method('getMarketingListBySegment')->with($this->equalTo(true))->will($this->returnValue(new \stdClass()));
$this->listener->onPreBuild($event);
$this->assertEquals($expected, $config->offsetGetByPath(CampaignStatisticDatagridListener::PATH_GROUPBY));
}
示例12: testVisitDatasourceNoPagerRestrictions
/**
* @param array $config
* @param int $page
* @param int $maxPerPage
* @dataProvider visitDatasourceNoRestrictionsDataProvider
*/
public function testVisitDatasourceNoPagerRestrictions(array $config, $page, $maxPerPage)
{
$this->pager->expects($this->once())->method('setPage')->with($page);
$this->pager->expects($this->once())->method('setMaxPerPage')->with($maxPerPage);
/** @var DatasourceInterface $dataSource */
$dataSource = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datasource\\DatasourceInterface');
$configObject = DatagridConfiguration::create($config);
$this->extension->setParameters(new ParameterBag());
$this->extension->visitDatasource($configObject, $dataSource);
}
示例13: testBuildBeforeFrontendItems
/**
* @param array $inputData
* @param array $expectedData
* @dataProvider buildBeforeFrontendQuotesProvider
*/
public function testBuildBeforeFrontendItems(array $inputData, array $expectedData)
{
$this->securityProvider->expects($this->any())->method('isGrantedViewLocal')->with($this->entityClass)->willReturn($inputData['grantedViewLocal']);
$this->securityProvider->expects($this->any())->method('isGrantedViewAccountUser')->with($this->entityClass)->willReturn($inputData['grantedViewAccountUser']);
$this->securityProvider->expects($this->any())->method('getLoggedUser')->willReturn($inputData['user']);
$datagridConfig = DatagridConfiguration::create($inputData['config']);
$event = new BuildBefore($this->datagrid, $datagridConfig);
$this->listener->onBuildBeforeFrontendItems($event);
$this->assertEquals($expectedData['config'], $datagridConfig->toArray());
}
示例14: testOnBuildBefore
public function testOnBuildBefore()
{
$entityClassResolver = $this->getMockBuilder('Oro\\Bundle\\EntityBundle\\ORM\\EntityClassResolver')->disableOriginalConstructor()->getMock();
$entityClassResolver->expects($this->any())->method('getEntityClass')->willReturn('Oro\\Bundle\\TagBundle\\Tests\\Unit\\Fixtures\\Taggable');
$listener = new TagsGridListener($entityClassResolver);
$config = DatagridConfiguration::create(['name' => 'test_grid', 'extended_entity_name' => 'Oro\\Bundle\\TagBundle\\Tests\\Unit\\Fixtures\\Taggable', 'source' => ['query' => ['select' => ['t.id'], 'from' => [['table' => 'Oro\\Bundle\\TagBundle\\Tests\\Unit\\Fixtures\\Taggable', 'alias' => 't']]]], 'columns' => ['id' => ['label' => 'id']], 'filters' => ['columns' => ['id' => ['type' => 'string']]]]);
$datagrid = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datagrid\\Datagrid')->disableOriginalConstructor()->getMock();
$event = new BuildBefore($datagrid, $config);
$listener->onBuildBefore($event);
$this->assertEquals(['type' => 'tag', 'label' => 'oro.tag.entity_plural_label', 'data_name' => 'tag.id', 'enabled' => false, 'options' => ['field_options' => ['entity_class' => 'Oro\\Bundle\\TagBundle\\Tests\\Unit\\Fixtures\\Taggable']]], $config->offsetGetByPath('[filters][columns][tagname]'));
}
示例15: testEventCreation
public function testEventCreation()
{
$grid = $this->getMockForAbstractClass('Oro\\Bundle\\DataGridBundle\\Datagrid\\DatagridInterface');
$config = DatagridConfiguration::create([]);
$event = new BuildBefore($grid, $config);
$this->assertSame($grid, $event->getDatagrid());
$this->assertSame($config, $event->getConfig());
// test config passed as link
$event->getConfig()->offsetSet(self::TEST_STRING, self::TEST_STRING . 'value');
$this->assertEquals(self::TEST_STRING . 'value', $config->offsetGet(self::TEST_STRING));
}