setRoles(['ROLE_TEAMER']); $this->assertTrue($this->createCheck()->appliesTo($user)); } /** * @dataProvider mixedRoleProvider */ public function testDoesNotApplyToExcludedMixedRoleUsersWithTeamerRole(string $excludedRole): void { $user = (new User())->setRoles([$excludedRole, 'ROLE_TEAMER']); $this->assertFalse($this->createCheck()->appliesTo($user)); } public function mixedRoleProvider(): array { return [ ['ROLE_ADMIN'], ['ROLE_MANAGER'], ['ROLE_HOUSE_MANAGER'], ]; } public function testRedirectsToItsOwnConfirmationPage(): void { // not the profile form, which demands the whole 'profile' group and can // therefore be impossible to submit $this->assertSame('app_teamer_check_personal_data', $this->createCheck()->getRouteName()); } public function testIsNotSatisfiedWhenTeamerIsMissing(): void { $user = (new User())->setRoles(['ROLE_TEAMER']); $this->assertFalse($this->createCheck()->isSatisfied($user)); } public function testToleratesAnUnpersistedTeamerWithoutACreationDate(): void { CarbonImmutable::setTestNow('2026-01-20 12:00:00'); // Teamer::getCreatedAt() is declared non-nullable but throws until flushed $this->assertFalse($this->createCheck()->isSatisfied($this->createUser(new Teamer()))); } public function testDelegatesTheDueDecisionToItsSchedule(): void { CarbonImmutable::setTestNow('2026-01-20 12:00:00'); $teamer = (new Teamer())->setCreatedAt(new \DateTimeImmutable('2025-11-05 12:00:00')); $user = $this->createUser($teamer); $this->assertFalse($this->createCheck()->isSatisfied($user)); $teamer->setDataVerifiedAt(new \DateTimeImmutable('2026-01-16 10:00:00')); $this->assertTrue($this->createCheck()->isSatisfied($user)); } public function testAnEmptyScheduleNeverForcesVerification(): void { CarbonImmutable::setTestNow('2026-01-20 12:00:00'); $teamer = (new Teamer())->setCreatedAt(new \DateTimeImmutable('2025-11-05 12:00:00')); $check = new PersonalDataVerificationRequiredCheck(new RecurringDeadlines([])); $this->assertTrue($check->isSatisfied($this->createUser($teamer))); } private function createCheck(): PersonalDataVerificationRequiredCheck { return new PersonalDataVerificationRequiredCheck(new RecurringDeadlines(['01-15', '07-15'])); } private function createUser(Teamer $teamer): User { return (new User()) ->setRoles(['ROLE_TEAMER']) ->setTeamer($teamer) ; } }