/**
  * Test method getAcceptedDataSource
  */
 public function testGetAcceptedDataSource()
 {
     $dataSource = $this->getMockForAbstractClass('Oro\\Bundle\\DataGridBundle\\Datasource\\DatasourceInterface');
     $this->grid->setDatasource($dataSource);
     $this->acceptor->expects($this->once())->method('acceptDatasource')->with($dataSource);
     $result = $this->grid->getAcceptedDatasource();
     $this->assertEquals($dataSource, $result);
 }
 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');
 }