コード例 #1
0
 /**
  * @dataProvider testOnBuildAfterDataProvider
  *
  * @param string                       $alias
  * @param string|null                  $entityClass
  * @param EntityAliasNotFoundException $exception
  */
 public function testOnBuildAfter($alias, $entityClass = null, EntityAliasNotFoundException $exception = null)
 {
     $this->event->expects($this->once())->method('getDatagrid')->will($this->returnValue($this->datagrid));
     $qb = $this->assertOrmDataSource();
     $this->assertAclCall($qb);
     $tagId = 100;
     $this->parameters->expects($this->at(0))->method('get')->with('tag_id', 0)->will($this->returnValue($tagId));
     $qb->expects($this->at(0))->method('setParameter')->with('tag', $tagId);
     $this->parameters->expects($this->at(1))->method('get')->with('from', '')->will($this->returnValue($alias));
     if (strlen($alias) > 0) {
         $earMockBuilder = $this->entityAliasResolver->expects($this->once())->method('getClassByAlias')->with($alias);
         if (null !== $entityClass) {
             $earMockBuilder->willReturn($entityClass);
             $qb->expects($this->at(1))->method('andWhere')->with('tt.entityName = :entityClass')->willReturn($qb);
             $qb->expects($this->at(2))->method('setParameter')->with('entityClass', $entityClass);
         } else {
             $earMockBuilder->willThrowException($exception);
             $qb->expects($this->at(1))->method('1 = 0');
         }
     }
     $this->listener->onBuildAfter($this->event);
 }