diff --git a/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarACL.php b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarACL.php new file mode 100644 index 000000000..6915f2e89 --- /dev/null +++ b/src/Bundle/ChillCalendarBundle/DataFixtures/ORM/LoadCalendarACL.php @@ -0,0 +1,55 @@ +setRole($role); + $manager->persist($r); + } + + foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) { + /** @var PermissionsGroup $group */ + $group = $this->getReference($permissionGroupRef); + + foreach ($roleScopes as $scope) { + $group->addRoleScope($scope); + } + } + + $manager->flush(); + } + + public function getOrder(): int + { + return 16000; + } + +} diff --git a/src/Bundle/ChillCalendarBundle/Resources/config/services/fixtures.yml b/src/Bundle/ChillCalendarBundle/Resources/config/services/fixtures.yml index 2bef0bdc4..c57011511 100644 --- a/src/Bundle/ChillCalendarBundle/Resources/config/services/fixtures.yml +++ b/src/Bundle/ChillCalendarBundle/Resources/config/services/fixtures.yml @@ -1,13 +1,10 @@ --- services: - Chill\CalendarBundle\DataFixtures\ORM\LoadCancelReason: - tags: - - { 'name': doctrine.fixture.orm } - Chill\CalendarBundle\DataFixtures\ORM\LoadInvite: - tags: - - { 'name': doctrine.fixture.orm } - Chill\CalendarBundle\DataFixtures\ORM\LoadCalendarRange: - autowire: true - autoconfigure: true - tags: - - { 'name': doctrine.fixture.orm } \ No newline at end of file + _defaults: + autowire: true + autoconfigure: true + + Chill\CalendarBundle\DataFixtures\ORM\: + resource: './../../../DataFixtures/ORM' + tags: + - { 'name': doctrine.fixture.orm } diff --git a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php index f53fe1dea..6d6d53b0a 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\CalendarBundle\Tests\Controller; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; @@ -42,14 +43,32 @@ final class CalendarControllerTest extends WebTestCase $nb = $em->createQueryBuilder() ->from(AccompanyingPeriod::class, 'ac') - ->select('COUNT(ac) AS nb') + ->join('ac.participations', 'acp') + ->join('acp.person', 'person') + ->join('person.centerCurrent', 'pc') + ->join('pc.center', 'center') + ->where('center.name LIKE :n') + ->setParameter('n', 'Center A') + ->join('ac.scopes', 's') + ->andWhere('JSON_EXTRACT(s.name,\'fr\') LIKE :s') + ->setParameter('s', 'social') + ->select('COUNT(DISTINCT ac) AS nb') ->getQuery() ->getSingleScalarResult(); yield [$em->createQueryBuilder() ->from(AccompanyingPeriod::class, 'ac') ->select('ac.id') - ->setFirstResult(random_int(0, $nb)) + ->join('ac.participations', 'acp') + ->join('acp.person', 'person') + ->join('person.centerCurrent', 'pc') + ->join('pc.center', 'center') + ->where('center.name LIKE :n') + ->setParameter('n', 'Center A') + ->join('ac.scopes', 's') + ->andWhere('JSON_EXTRACT(s.name,\'fr\') LIKE :s') + ->setParameter('s', 'social') + ->setFirstResult(random_int(0, $nb - 1)) ->setMaxResults(1) ->getQuery() ->getSingleScalarResult(), @@ -63,7 +82,7 @@ final class CalendarControllerTest extends WebTestCase { $this->client->request( Request::METHOD_GET, - sprintf('/fr/calendar/calendar/?accompanying_period_id=%d', $accompanyingPeriodId) + sprintf('/fr/calendar/calendar/by-period/%d', $accompanyingPeriodId) ); $this->assertEquals(200, $this->client->getResponse()->getStatusCode());