예제 #1
0
 /**
  * @dataProvider dataProvider
  */
 public function testApply(QueryBuilder $queryBuilder, $conditions, $resultHandler, $walkerResult, $exception)
 {
     $eventDispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
     $this->conditionBuilder = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\ORM\\Walker\\OwnershipConditionDataBuilder')->disableOriginalConstructor()->getMock();
     $this->conditionBuilder->expects($this->any())->method('getAclConditionData')->will($this->returnCallback(function ($entityName, $permission) use($conditions) {
         if (isset($conditions[$entityName])) {
             return $conditions[$entityName];
         }
         return null;
     }));
     $conditionalFactorBuilder = new AclConditionalFactorBuilder();
     $this->helper = new AclHelper($this->conditionBuilder, $eventDispatcher, $conditionalFactorBuilder);
     $query = $this->helper->apply($queryBuilder);
     $this->{$resultHandler}($query->getHints());
     $parserResult = $this->getMockBuilder('Doctrine\\ORM\\Query\\ParserResult')->disableOriginalConstructor()->getMock();
     $this->assertEquals($query->getDQL(), $queryBuilder->getDQL());
     $this->walker = new AclWalker($query, $parserResult, []);
     $resultAst = $this->walker->walkSelectStatement($query->getAST());
     $this->{$walkerResult}($resultAst);
     if ($exception) {
         list($class, $message) = $exception;
         $this->setExpectedException($class, $message);
     }
     $this->assertNotEmpty($query->getSQL());
 }
 /**
  * @dataProvider dataProvider
  */
 public function testApply(QueryBuilder $queryBuilder, $conditions, $resultHandler, $walkerResult)
 {
     $this->conditionBuilder = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\ORM\\Walker\\OwnershipConditionDataBuilder')->disableOriginalConstructor()->getMock();
     $this->conditionBuilder->expects($this->any())->method('getAclConditionData')->will($this->returnCallback(function ($entityName, $permission) use($conditions) {
         if (isset($conditions[$entityName])) {
             return $conditions[$entityName];
         }
         return null;
     }));
     $this->helper = new AclHelper($this->conditionBuilder);
     $query = $this->helper->apply($queryBuilder);
     $this->{$resultHandler}($query->getHints());
     $parserResult = $this->getMockBuilder('Doctrine\\ORM\\Query\\ParserResult')->disableOriginalConstructor()->getMock();
     $this->assertEquals($query->getDQL(), $queryBuilder->getDQL());
     $this->walker = new AclWalker($query, $parserResult, []);
     $resultAst = $this->walker->walkSelectStatement($query->getAST());
     $this->{$walkerResult}($resultAst);
 }