/** * Test method getMetaData */ public function testGetMetaData() { $resultFQCN = 'Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\MetadataObject'; $this->acceptor->expects($this->once())->method('acceptMetadata')->with($this->isInstanceOf($resultFQCN)); $result = $this->grid->getMetadata(); $this->assertInstanceOf($resultFQCN, $result); }
public function testIsApplicableFalse() { $config = DatagridConfiguration::create([]); $datagrid = new Datagrid('test', $config, new ParameterBag()); $event = new BuildBefore($datagrid, $datagrid->getConfig()); $this->listener->onBuildBefore($event); $this->assertEquals(null, $event->getConfig()->offsetGetByPath(sprintf(GridListener::ACTION_CONFIGURATION_KEY, MassUpdateActionHandler::ACTION_NAME)), 'Failed asserting that mass action was not configured'); }
/** * {@inheritdoc} */ public function initialize() { parent::initialize(); // set entity to FROM part of a query $from = $this->config->offsetGetByPath(self::PATH_FROM, []); $from[0]['table'] = $this->parameters->get('class_name'); $this->config->offsetSetByPath(self::PATH_FROM, $from); }
public function testBuildAfter() { $config = DatagridConfiguration::createNamed(self::TEST_GRID_NAME, []); $acceptor = new Acceptor(); $acceptor->setConfig($config); $parameters = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datagrid\\ParameterBag'); $grid = new Datagrid(self::TEST_GRID_NAME, $config, $parameters); $grid->setAcceptor($acceptor); $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock(); $qb->expects($this->once())->method('getDQLPart')->with($this->equalTo('from'))->will($this->returnValue([new From(self::TEST_ENTITY_NAME, 'alias')])); $datasourceMock = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock(); $datasourceMock->expects($this->any())->method('getQueryBuilder')->will($this->returnValue($qb)); $this->generator->expects($this->once())->method('generate')->with(self::TEST_ENTITY_NAME)->will($this->returnValue([])); $grid->setDatasource($datasourceMock); $event = new BuildAfter($grid); $this->listener->buildAfter($event); $this->assertContains('oronavigation/js/content/grid-builder', $config->offsetGetByPath(sprintf('%s[%s]', ToolbarExtension::OPTIONS_PATH, MetadataObject::REQUIRED_MODULES_KEY)), 'Should add require js module'); }
public function testGetParameters() { $this->assertSame($this->parameters, $this->grid->getParameters()); }