buildEventACLAwareRepository(); $this->assertGreaterThanOrEqual(0, $repository->countAllViewable($filters)); } /** * @dataProvider generateFilters */ public function testFindAllViewable(array $filters): void { $repository = $this->buildEventACLAwareRepository(); $this->assertIsArray($repository->findAllViewable($filters)); } public function generateFilters(): iterable { yield [[]]; } public function buildEventACLAwareRepository(): EventACLAwareRepository { $em = self::$container->get(EntityManagerInterface::class); $user = $em->createQuery('SELECT u FROM '.User::class.' u') ->setMaxResults(1) ->getSingleResult() ; $scopes = $em->createQuery('SELECT s FROM '.Scope::class.' s') ->setMaxResults(3) ->getResult(); $centers = $em->createQuery('SELECT c FROM '.Center::class.' c') ->setMaxResults(3) ->getResult(); $security = $this->prophesize(Security::class); $security->getUser()->willReturn($user); $authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class); $authorizationHelper->getReachableCenters(EventVoter::SEE)->willReturn($centers); $authorizationHelper->getReachableScopes(EventVoter::SEE, Argument::type(Center::class))->willReturn($scopes); return new EventACLAwareRepository( $authorizationHelper->reveal(), $em, $security->reveal() ); } }