コード例 #1
0
 /**
  * @param array $dqlParts
  * @param bool  $expected
  * @param       bool false
  *
  * @dataProvider dataSourceDataProvider
  */
 public function testVisitDatasource($dqlParts, $expected, $isObject = false)
 {
     $marketingListId = 1;
     $nonManualMarketingList = $this->getMockBuilder('OroCRM\\Bundle\\MarketingListBundle\\Entity\\MarketingList')->disableOriginalConstructor()->getMock();
     $nonManualMarketingList->expects($this->once())->method('isManual')->will($this->returnValue(false));
     $gridName = 'test_grid';
     $config = $this->assertIsApplicable($marketingListId, $nonManualMarketingList, $gridName);
     $dataSource = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock();
     $qb = $this->getQbMock();
     if (!empty($dqlParts['where'])) {
         /** @var Andx $where */
         $where = $dqlParts['where'];
         $parts = $where->getParts();
         if ($expected && !$isObject) {
             $qb->expects($this->exactly(count($parts)))->method('andWhere');
         } elseif ($expected && $isObject) {
             $qb->expects(static::any())->method('andWhere');
         }
         $functionParts = array_filter($parts, function ($part) {
             return !is_string($part);
         });
         if ($functionParts && $expected) {
             $qb->expects($this->once())->method('setParameter')->with($this->equalTo('marketingListId'), $this->equalTo($marketingListId));
         }
     }
     if ($expected) {
         $qb->expects($this->once())->method('getDQLParts')->will($this->returnValue($dqlParts));
         $dataSource->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($qb));
     }
     $this->extension->visitDatasource($config, $dataSource);
 }
コード例 #2
0
 /**
  * @param array $dqlParts
  * @param bool  $isMixin
  * @param bool  $expected
  *
  * @dataProvider dataSourceDataProvider
  */
 public function testVisitDatasource($dqlParts, $isMixin, $expected)
 {
     $config = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\DatagridConfiguration')->disableOriginalConstructor()->getMock();
     $this->repository->expects($this->any())->method('findOneBy')->will($this->returnValue(new \stdClass()));
     $id = '1';
     $config->expects($this->any())->method('offsetGetByPath')->will($this->returnValueMap([['[source][type]', null, OrmDatasource::TYPE], ['[name]', null, Segment::GRID_PREFIX . $id], [MarketingListExtension::OPTIONS_MIXIN_PATH, false, $isMixin]]));
     $dataSource = $this->getMockBuilder('Oro\\Bundle\\DataGridBundle\\Datasource\\Orm\\OrmDatasource')->disableOriginalConstructor()->getMock();
     $qb = $this->getQbMock();
     if (!empty($dqlParts['where'])) {
         /** @var Andx $where */
         $where = $dqlParts['where'];
         $parts = $where->getParts();
         if ($expected) {
             $qb->expects($this->exactly(sizeof($parts)))->method('andWhere');
         }
         $functionParts = array_filter($parts, function ($part) {
             return !is_string($part);
         });
         if ($functionParts && $expected) {
             $qb->expects($this->once())->method('setParameter')->with($this->equalTo('segmentId'), $this->equalTo($id));
         }
     }
     if ($expected) {
         $qb->expects($this->once())->method('getDQLParts')->will($this->returnValue($dqlParts));
         $dataSource->expects($this->once())->method('getQueryBuilder')->will($this->returnValue($qb));
     }
     $this->extension->visitDatasource($config, $dataSource);
 }