public function testGetEmptyList()
 {
     $businessUnitRepository = $this->getMockBuilder('BusinessUnitRepository')->disableOriginalConstructor()->setMethods(['getQueryBuilder'])->getMock();
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->setMethods(['getResult'])->disableOriginalConstructor()->getMock();
     $this->aclHelper->expects($this->any())->method('apply')->willReturn($qb);
     $businessUnitRepository->expects($this->any())->method('getQueryBuilder')->willReturn($qb);
     $qb->expects($this->any())->method('getResult')->willReturn([]);
     $this->registry->expects($this->once())->method('getRepository')->with('OroOrganizationBundle:BusinessUnit')->willReturn($businessUnitRepository);
     $result = $this->choiceTreeBusinessUnitProvider->getList();
     $this->assertEquals([], $result);
 }
 /**
  * @dataProvider getListDataProvider
  */
 public function testGetList($userBUIds, $queryResult, $result)
 {
     $businessUnitRepos = $this->getMockBuilder('BusinessUnitRepository')->disableOriginalConstructor()->setMethods(['getQueryBuilder'])->getMock();
     $qb = $this->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->setMethods(['getResult', 'expr', 'setParameter'])->disableOriginalConstructor()->getMock();
     $treeOwner = $this->getMockBuilder('Oro\\Bundle\\SecurityBundle\\Owner\\OwnerTree')->setMethods(['getUserSubordinateBusinessUnitIds'])->disableOriginalConstructor()->getMock();
     $this->treeProvider->expects(self::once())->method('getTree')->willReturn($treeOwner);
     $treeOwner->expects(self::once())->method('getUserSubordinateBusinessUnitIds')->willReturn($userBUIds);
     $this->aclHelper->expects(self::any())->method('apply')->willReturn($qb);
     $businessUnitRepos->expects(self::any())->method('getQueryBuilder')->willReturn($qb);
     $expression = $this->getMockBuilder('Doctrine\\ORM\\Query\\Expr')->setMethods(['in'])->disableOriginalConstructor()->getMock();
     $qb->expects(self::once())->method('getResult')->willReturn($queryResult);
     $qb->expects(self::once())->method('expr')->willReturn($expression);
     $qb->expects(self::once())->method('setParameter');
     $tokenStorage = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
     $user = $this->getMockBuilder('Oro\\Bundle\\UserBundle\\Entity\\User')->setMethods(['getId', 'getOrganizations'])->disableOriginalConstructor()->getMock();
     $organization = $this->getMock('Oro\\Bundle\\OrganizationBundle\\Entity\\OrganizationInterface');
     $organization->expects(self::once())->method('getId')->willReturn(1);
     $user->expects(self::once())->method('getOrganizations')->willReturn([$organization]);
     $this->securityFacade->expects(self::once())->method('getToken')->willReturn($tokenStorage);
     $tokenStorage->expects(self::once())->method('getUser')->willReturn($user);
     $this->registry->expects(self::once())->method('getRepository')->with('OroOrganizationBundle:BusinessUnit')->willReturn($businessUnitRepos);
     $resultedUserBUids = $this->choiceTreeBUProvider->getList();
     self::assertEquals($result, $resultedUserBUids);
 }