*/ #[CoversClass(QuickEntryTimesheet::class)] #[CoversClass(QuickEntryTimesheetValidator::class)] class QuickEntryTimesheetValidatorTest extends ConstraintValidatorTestCase { protected function createConstraint(): QuickEntryTimesheet { return new QuickEntryTimesheet(); } protected function createValidator(): ConstraintValidatorInterface { return new QuickEntryTimesheetValidator([new TimesheetBasic()]); } public function testConstraintIsInvalid(): void { $this->expectException(UnexpectedTypeException::class); $this->validator->validate(new Timesheet(), new NotBlank()); } public function testInvalidValueThrowsException(): void { $this->expectException(UnexpectedTypeException::class); $this->validator->validate(new Activity(), $this->createConstraint()); } public function testNotTriggersOnEmptyDurationAndNewTimesheet(): void { $timesheet = new Timesheet(); $timesheet->setDuration(null); $this->validator->validate($timesheet, $this->createConstraint()); $this->assertNoViolation(); } }