weekly quick-entry form (#2793)

This commit is contained in:
Kevin Papst
2021-10-18 11:12:46 +02:00
committed by GitHub
parent 64893e0a95
commit 9ab098af86
105 changed files with 3356 additions and 778 deletions

View File

@@ -19,6 +19,7 @@ use Symfony\Component\Validator\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
/**
* @covers \App\Validator\Constraints\TimesheetLongRunning
* @covers \App\Validator\Constraints\TimesheetLongRunningValidator
*/
class TimesheetLongRunningValidatorTest extends ConstraintValidatorTestCase
@@ -73,6 +74,33 @@ class TimesheetLongRunningValidatorTest extends ConstraintValidatorTestCase
->assertRaised();
}
public function testLongRunningTriggersOverMaximum()
{
$timesheet = new Timesheet();
$timesheet->setBegin(new \DateTime());
$timesheet->setEnd(new \DateTime());
$timesheet->setDuration(31536001);
$this->validator->validate($timesheet, new TimesheetLongRunning());
$this->buildViolation('Maximum duration exceeded.')
->atPath('property.path.duration')
->setCode(TimesheetLongRunning::MAXIMUM)
->assertRaised();
}
public function testLongRunningDoesNotTriggerOnMaximum()
{
$timesheet = new Timesheet();
$timesheet->setBegin(new \DateTime());
$timesheet->setEnd(new \DateTime());
$timesheet->setDuration(31536000);
$this->validator->validate($timesheet, new TimesheetLongRunning());
$this->assertNoViolation();
}
public function testLongRunningNotTriggersIfConfiguredToZero()
{
$this->validator = $this->createMyValidator(0);
@@ -114,4 +142,10 @@ class TimesheetLongRunningValidatorTest extends ConstraintValidatorTestCase
$this->validator->validate($timesheet, new TimesheetLongRunning());
$this->assertNoViolation();
}
public function testGetTargets()
{
$constraint = new TimesheetLongRunning();
self::assertEquals('class', $constraint->getTargets());
}
}