mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-10 06:53:45 +00:00
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:
@@ -26,6 +26,7 @@ use Chill\TicketBundle\Security\Voter\TicketVoter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@@ -48,15 +49,16 @@ class TicketACLAwareRepositoryTest extends KernelTestCase
|
||||
$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);
|
||||
$innerSecurity = $this->prophesize(Security::class);
|
||||
$innerSecurity->getUser()->willReturn($user);
|
||||
$security = new ChillSecurity($innerSecurity->reveal());
|
||||
|
||||
$authorizationHelper = $this->prophesize(AuthorizationHelperForCurrentUserInterface::class);
|
||||
$authorizationHelper->getReachableCenters(TicketVoter::READ)->willReturn($centers);
|
||||
|
||||
$this->repository = new TicketACLAwareRepository(
|
||||
$this->entityManager,
|
||||
$security->reveal(),
|
||||
$security,
|
||||
$authorizationHelper->reveal(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user