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')); }
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); }
public function testVisitResult() { $result = ResultsObject::create([]); $this->extension->visitResult(DatagridConfiguration::create([]), $result); $this->assertArrayHasKey('metadata', $result); $this->assertInternalType('array', $result['metadata']); }
/** * @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()); }
/** * 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()); }
/** * @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); }
/** * @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); }
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()); }
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()); }
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); }
/** * @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)); }
/** * @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); }
/** * @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()); }
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]')); }
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)); }
public function testOnBuildBeforeCustomerGroups() { /** @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->onBuildBeforeCustomerGroups($event); $expected = $this->expectedTemplate; $expected['source']['query']['join']['left'][0]['condition'] = 'customer_group MEMBER OF priceList.customerGroups'; $this->assertEquals($expected, $config->toArray()); }
public function testSetOptionsWithDataGridColumnsDefinitionMerge() { $datagrid = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datagrid\\DatagridInterface'); $columnsDefintion = array('bar' => array('name' => 'bar', 'label' => 'Foo label', 'frontend_type' => 'int')); $config = DatagridConfiguration::create(array('columns' => $columnsDefintion)); $datagrid->expects($this->once())->method('getConfig')->will($this->returnValue($config)); $options = array('name' => 'foo', 'data_schema' => array('foo' => 'bar'), 'settings' => array()); $expectedOptions = $options; $expectedOptions['data_schema'] = array('foo' => array('field_name' => 'bar', 'label' => 'Foo label', 'type' => 'int')); $this->assertEquals($this->builder, $this->builder->setDataGrid($datagrid)->setOptions($options)); $this->assertAttributeEquals($expectedOptions, 'options', $this->builder); }
/** * @dataProvider onBuildAfterDataProvider * @param array $config * @param array $expectedBindParameters */ public function testOnBuildAfterWorks(array $config, array $expectedBindParameters = null) { $config = DatagridConfiguration::create($config); $this->event->expects($this->once())->method('getDatagrid')->will($this->returnValue($this->datagrid)); $this->datagrid->expects($this->once())->method('getDatasource')->will($this->returnValue($this->datasource)); $this->datagrid->expects($this->once())->method('getConfig')->will($this->returnValue($config)); if ($expectedBindParameters) { $this->datasource->expects($this->once())->method('bindParameters')->with($expectedBindParameters); } else { $this->datasource->expects($this->never())->method($this->anything()); } $this->listener->onBuildAfter($this->event); }
public function testWithFilter() { $this->request->query->set('magento-customers-grid', ['_filter' => ['isSubscriber' => ['value' => 'yes']]]); $config = DatagridConfiguration::create([]); $config->offsetSetByPath('[source][query][select]', ['c.id', 'c.firstName']); $parameters = new ParameterBag(); $event = new PreBuild($config, $parameters); $this->assertEmpty($config->offsetGetByPath('[source][query][join][left]')); $this->listener->onPreBuild($event); $this->assertArrayHasKey('isSubscriber', $config->offsetGetByPath('[filters][columns]')); $this->assertEquals('DISTINCT c.id', $config->offsetGetByPath('[source][query][select][0]')); $this->assertContains('isSubscriber', $config->offsetGetByPath('[source][query][select][2]')); $this->assertCount(3, $config->offsetGetByPath('[source][query][join][left]')); }
/** * @param array $configValues * @param string $entityName * @dataProvider setParametersDataProvider */ public function testProcessConfigs(array $configValues, $entityName) { $config = DatagridConfiguration::create($configValues); $callback = $this->getProcessConfigsCallBack(); $this->guesser->expects($this->any())->method('getColumnOptions')->will($this->returnCallback($callback)); $this->entityClassNameHelper->expects($this->any())->method('getUrlSafeClassName')->willReturn('Oro_Bundle_EntityBundle_Tests_Unit_Fixtures_Stub_SomeEntity'); $this->extension->processConfigs($config); $expectedValues = $this->getProcessConfigsExpectedValues($entityName); $expectedResult = DatagridConfiguration::create($expectedValues); $key = Configuration::BASE_CONFIG_KEY; $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key)); $key = FormatterConfiguration::COLUMNS_KEY; $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key)); }
/** * @param int|null $priceListId * @param array $priceCurrencies * @param array $expectedConfig * @dataProvider onBuildBeforeDataProvider */ public function testOnBuildBefore($priceListId = null, array $priceCurrencies = [], array $expectedConfig = []) { if ($priceListId && $priceCurrencies) { $this->priceListRequestHandler->expects($this->any())->method('getPriceList')->willReturn($this->getPriceList($priceListId)); $this->priceListRequestHandler->expects($this->any())->method('getPriceListSelectedCurrencies')->will($this->returnCallback(function () use($priceCurrencies) { return array_intersect(['USD', 'EUR'], $priceCurrencies); })); } /** @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->onBuildBefore($event); $this->assertEquals($expectedConfig, $config->toArray()); }
/** * @param bool $isGranted * @param null|int $user * @param bool $hasAccount * @param array $expected * @dataProvider onBuildBeforeProvider */ public function testOnBuildBefore($isGranted = false, $user = null, $hasAccount = true, array $expected = []) { /** @var \PHPUnit_Framework_MockObject_MockObject|DatagridInterface $datagrid */ $datagrid = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datagrid\\DatagridInterface'); $config = DatagridConfiguration::create([]); if ($user) { $this->securityFacade->expects($this->once())->method('isGranted')->with('orob2b_account_frontend_account_user_role_view')->willReturn($isGranted); } if ($hasAccount) { $this->mockUser($user); } $event = new BuildBefore($datagrid, $config); $this->listener->onBuildBefore($event); $this->assertEquals($expected, $config->toArray()); }
/** * @dataProvider onBuildAfterDataProvider */ public function testOnBuildAfterWorks(array $config, array $expectedConfig, $expectedBindParameters) { $config = DatagridConfiguration::create($config); $this->event->expects($this->once())->method('getDatagrid')->will($this->returnValue($this->datagrid)); $this->datagrid->expects($this->once())->method('getDatasource')->will($this->returnValue($this->datasource)); $this->datagrid->expects($this->once())->method('getConfig')->will($this->returnValue($config)); if ($expectedBindParameters) { $expectedBindParameters = ['data_in' => ['name' => RowSelectionListener::GRID_PARAM_DATA_IN, 'path' => ParameterBag::ADDITIONAL_PARAMETERS . '.' . RowSelectionListener::GRID_PARAM_DATA_IN, 'default' => [0]], 'data_not_in' => ['name' => RowSelectionListener::GRID_PARAM_DATA_NOT_IN, 'path' => ParameterBag::ADDITIONAL_PARAMETERS . '.' . RowSelectionListener::GRID_PARAM_DATA_NOT_IN, 'default' => [0]]]; $this->datasource->expects($this->once())->method('bindParameters')->with($expectedBindParameters); } else { $this->datasource->expects($this->never())->method($this->anything()); } $this->listener->onBuildAfter($this->event); $this->assertEquals($expectedConfig, $config->toArray()); }
public function testVisitMetadataShouldAddGridViewsFromEvent() { $this->gridViewsExtension->setParameters(new ParameterBag()); $data = MetadataObject::create([]); $config = DatagridConfiguration::create([DatagridConfiguration::NAME_KEY => 'grid']); $this->eventDispatcher->expects($this->once())->method('hasListeners')->with(GridViewsLoadEvent::EVENT_NAME)->will($this->returnValue(true)); $expectedViews = ['views' => [(new View('name', ['k' => 'v'], ['k2' => 'v2']))->getMetadata()], 'permissions' => ['CREATE' => true, 'EDIT' => true, 'VIEW' => true, 'DELETE' => true, 'SHARE' => true, 'EDIT_SHARED' => true], 'gridName' => 'grid']; $this->eventDispatcher->expects($this->once())->method('dispatch')->with(GridViewsLoadEvent::EVENT_NAME)->will($this->returnCallback(function ($eventName, GridViewsLoadEvent $event) use($expectedViews) { $event->setGridViews($expectedViews); return $event; })); $this->assertFalse($data->offsetExists('gridViews')); $this->gridViewsExtension->visitMetadata($config, $data); $this->assertTrue($data->offsetExists('gridViews')); $this->assertEquals($expectedViews, $data->offsetGet('gridViews')); }
public function testProcessConfigs() { $entityName = 'Oro\\Bundle\\EntityBundle\\Tests\\Unit\\Fixtures\\Stub\\SomeEntity'; $configValues = [Configuration::BASE_CONFIG_KEY => ['enable' => true, 'entity_name' => $entityName], FormatterConfiguration::COLUMNS_KEY => ['testText' => ['label' => 'test_text'], 'testSelect' => ['label' => 'test_select', PropertyInterface::FRONTEND_TYPE_KEY => 'string'], 'testAnotherText' => ['label' => 'test_config_overwrite', 'inline_editing' => ['enable' => false]], 'id' => ['label' => 'test_black_list'], 'updatedAt' => ['label' => 'test_black_list'], 'createdAt' => ['label' => 'test_black_list']]]; $config = DatagridConfiguration::create($configValues); $callback = $this->getProcessConfigsCallBack(); $this->guesser->expects($this->any())->method('getColumnOptions')->will($this->returnCallback($callback)); $this->entityClassNameHelper->expects($this->any())->method('getUrlSafeClassName')->willReturn('Oro_Bundle_EntityBundle_Tests_Unit_Fixtures_Stub_SomeEntity'); $this->extension->processConfigs($config); $expectedValues = $this->getProcessConfigsExpectedValues($entityName); $expectedResult = DatagridConfiguration::create($expectedValues); $key = Configuration::BASE_CONFIG_KEY; $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key)); $key = FormatterConfiguration::COLUMNS_KEY; $this->assertEquals($config->offsetGet($key), $expectedResult->offsetGet($key)); }
/** * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ public function testVisitDatasource() { $qb = new QueryBuilder($this->getTestEntityManager()); $qb->select(['user.id', 'user.name as user_name', 'user.status as user_status'])->from('Oro\\Bundle\\QueryDesignerBundle\\Tests\\Unit\\Fixtures\\Models\\CMS\\CmsUser', 'user')->join('user.address', 'address'); $manager = $this->getMockBuilder('Oro\\Bundle\\QueryDesignerBundle\\QueryDesigner\\Manager')->disableOriginalConstructor()->getMock(); $manager->expects($this->any())->method('createFilter')->will($this->returnCallback(function ($name, $params) { return $this->createFilter($name, $params); })); $extension = new OrmDatasourceExtension(new RestrictionBuilder($manager)); $datasource = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock(); $datasource->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($qb)); $config = DatagridConfiguration::create(['source' => ['query_config' => ['filters' => [['column' => 'user_name', 'filter' => 'string', 'filterData' => ['type' => '2', 'value' => 'test_user_name'], 'columnAlias' => 'user_name'], 'AND', [['column' => 'user_status', 'filter' => 'datetime', 'filterData' => ['type' => '2', 'value' => ['start' => '2013-11-20 10:30', 'end' => '2013-11-25 11:30']]], 'AND', [[['column' => 'address.country', 'filter' => 'string', 'filterData' => ['type' => '1', 'value' => 'test_address_country'], 'columnAlias' => 'address_country'], 'OR', ['column' => 'address.city', 'filter' => 'string', 'filterData' => ['type' => '1', 'value' => 'test_address_city']]], 'OR', ['column' => 'address.zip', 'filter' => 'string', 'filterData' => ['type' => '1', 'value' => 'address_zip']]]]]]]]); $extension->visitDatasource($config, $datasource); $result = $qb->getDQL(); $counter = 0; $result = preg_replace_callback('/(:[a-z]+)(\\d+)/', function ($matches) use(&$counter) { return $matches[1] . ++$counter; }, $result); $this->assertEquals('SELECT user.id, user.name as user_name, user.status as user_status ' . 'FROM Oro\\Bundle\\QueryDesignerBundle\\Tests\\Unit\\Fixtures\\Models\\CMS\\CmsUser user ' . 'INNER JOIN user.address address ' . 'WHERE user_name NOT LIKE :string1 AND (' . '(user_status < :datetime2 OR user_status > :datetime3) AND ' . '(address.country LIKE :string4 OR address.city LIKE :string5 OR address.zip LIKE :string6)' . ')', $result); }
/** * @dataProvider visitDatasourceProvider */ public function testVisitDatasource($source, $expected) { $qb = new QueryBuilder($this->getTestEntityManager()); $qb->select(['user.id', 'user.name as user_name', 'user.status as user_status'])->from('Oro\\Bundle\\QueryDesignerBundle\\Tests\\Unit\\Fixtures\\Models\\CMS\\CmsUser', 'user')->join('user.address', 'address'); $manager = $this->getMockBuilder('Oro\\Bundle\\QueryDesignerBundle\\QueryDesigner\\Manager')->disableOriginalConstructor()->getMock(); $manager->expects($this->any())->method('createFilter')->will($this->returnCallback(function ($name, $params) { return $this->createFilter($name, $params); })); $extension = new OrmDatasourceExtension(new RestrictionBuilder($manager)); $datasource = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock(); $datasource->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($qb)); $config = DatagridConfiguration::create($source); $extension->visitDatasource($config, $datasource); $result = $qb->getDQL(); $counter = 0; $result = preg_replace_callback('/(:[a-z]+)(\\d+)/', function ($matches) use(&$counter) { return $matches[1] . ++$counter; }, $result); $this->assertEquals($expected, $result); }
/** * @param array $gridConfig * @param array $parameters * @param mixed $expected * * @dataProvider valuesDataProvider */ public function testGetValuesToApply(array $gridConfig, array $parameters, $expected) { $gridConfig = DatagridConfiguration::create($gridConfig); $dataSource = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock(); $filter = $this->getMock('Oro\\Bundle\\FilterBundle\\Filter\\FilterInterface'); $filter->expects($this->any())->method('getName')->will($this->returnValue('filter')); $form = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock(); $form->expects($this->any())->method('isSubmitted')->will($this->returnValue(false)); if (is_array($expected)) { $form->expects($this->once())->method('submit')->with($this->equalTo($expected)); } else { $form->expects($this->never())->method('submit'); } $filter->expects($this->any())->method('getForm')->will($this->returnValue($form)); $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock(); $dataSource->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($qb)); $this->extension->addFilter('string', $filter); $this->extension->setParameters(new ParameterBag($parameters)); $this->extension->visitDatasource($gridConfig, $dataSource); }
/** * @return \PHPUnit_Framework_MockObject_MockObject|\Oro\Bundle\DataGridBundle\Event\PreBuild */ protected function createPreBuildEvent() { $event = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Event\\PreBuild')->disableOriginalConstructor()->getMock(); $config = DatagridConfiguration::create([]); $event->expects($this->any())->method('getConfig')->willReturn($config); $params = new ParameterBag(); $event->expects($this->any())->method('getParameters')->willReturn($params); return $event; }
/** * @param string $gridName * @param array $existingParameters * @param array $additionalParameters * @param array $expectedParameters * * @dataProvider extendConfigurationDataProvider */ public function testExtendConfiguration($gridName, array $existingParameters, array $additionalParameters, array $expectedParameters) { $this->configProvider->expects($this->once())->method('getConfiguration')->will($this->returnValue(DatagridConfiguration::create($additionalParameters))); $this->assertEquals(DatagridConfiguration::create($expectedParameters)->toArray(), $this->helper->extendConfiguration(DatagridConfiguration::create($existingParameters), $gridName)->toArray()); }