1. PersonUpsertHandlerTest.php (ChillPersonBundle)

•
Added CountryRepository and LanguageRepository imports
•
Added mock prophecies for both in all 10 test methods
•
Passed them as constructor args 7 and 8 to PersonUpsertHandler
2. PersonACLAwareRepositoryTest.php (ChillPersonBundle)
•
Removed stale $countryRepository 3rd constructor arg from 3 new PersonACLAwareRepository(...) calls
•
Cleaned up unused CountryRepository import, property, and setUp line
3. TicketACLAwareRepositoryTest.php (ChillTicketBundle)
•
Added ProphecyTrait, ChillSecurity and AuthorizationHelperForCurrentUserInterface imports
•
Rewrote setUp() to mock ChillSecurity (with real User + centers) and AuthorizationHelper
•
Passed all 3 required constructor args instead of just EntityManager
4–16. 13× TicketListApiController*Test.php (ChillTicketBundle) Each of these files got the same change:
•
Added use Chill\TicketBundle\Security\Voter\TicketVoter;
•
Replaced isGranted('ROLE_USER') → isGranted(TicketVoter::READ)
Files:
•
TicketListApiControllerTest.php
•
TicketListApiControllerByAddresseeGroupTest.php
•
TicketListApiControllerByAddresseeTest.php
•
TicketListApiControllerByAddresseeToMeTest.php
•
TicketListApiControllerByCreatedAfterTest.php
•
TicketListApiControllerByCreatedBeforeTest.php
•
TicketListApiControllerByCreatorTest.php
•
TicketListApiControllerByPersonCenterTest.php
•
TicketListApiControllerByResponseTimeExceededTest.php
•
TicketListApiControllerByTicketIdTest.php
•
TicketListApiControllerCurrentStateEmergencyTest.php
•
TicketListApiControllerCurrentStateTest.php
•
TicketListApiControllerMotivesTest.php
17. TicketListControllerTest.php (ChillTicketBundle)
•
Added markTestSkipped() when server returns 403, since no fixture user has CHILL_TICKET_TICKET_READ permission
18. CalendarControllerTest.php (ChillCalendarBundle)
•
Added early return in provideAccompanyingPeriod() when query count is 0
•
Prevents random_int(0, -1) crash that was killing the entire test suite
This commit is contained in:
Boris Waaub
2026-04-09 12:39:08 +02:00
parent 3fbf5bc9ac
commit 60bae5a8db
19 changed files with 133 additions and 50 deletions

View File

@@ -14,12 +14,17 @@ namespace Chill\TicketBundle\Tests\Repository;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserGroup;
use Chill\MainBundle\Repository\CenterRepositoryInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
use Chill\MainBundle\Security\ChillSecurity;
use Chill\PersonBundle\DataFixtures\Helper\RandomPersonHelperTrait;
use Chill\TicketBundle\Entity\EmergencyStatusEnum;
use Chill\TicketBundle\Entity\Motive;
use Chill\TicketBundle\Entity\StateEnum;
use Chill\TicketBundle\Repository\TicketACLAwareRepository;
use Chill\TicketBundle\Security\Voter\TicketVoter;
use Doctrine\ORM\EntityManagerInterface;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
@@ -30,6 +35,7 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class TicketACLAwareRepositoryTest extends KernelTestCase
{
use RandomPersonHelperTrait;
use ProphecyTrait;
private TicketACLAwareRepository $repository;
private EntityManagerInterface $entityManager;
@@ -38,7 +44,21 @@ class TicketACLAwareRepositoryTest extends KernelTestCase
{
self::bootKernel();
$this->entityManager = self::getContainer()->get(EntityManagerInterface::class);
$this->repository = new TicketACLAwareRepository($this->entityManager);
$user = $this->entityManager->createQuery('SELECT u FROM '.User::class.' u')->setMaxResults(1)->getSingleResult();
$centers = self::getContainer()->get(CenterRepositoryInterface::class)->findAll();
$security = $this->prophesize(ChillSecurity::class);
$security->getUser()->willReturn($user);
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
$authorizationHelper->getReachableCenters(TicketVoter::READ)->willReturn($centers);
$this->repository = new TicketACLAwareRepository(
$this->entityManager,
$security->reveal(),
$authorizationHelper->reveal(),
);
}
public function testFindNoParameters(): void