added project start and end date (#1303)
* added sortable js library * activity in invoice is optional * added javascript widget for paginated boxes * fix activity dropdown for globals only * added timesheet service to reduce code duplication * use repository to query for teams in dropdowns * added project validator * validate project start and end against timesheet * include begin and end in dynamic form requests for projects * added timezone and language option to import flag, improve timesheet import speed * deactivate cross-timezone filter * add virtual fields to field order list * composer update * added param to ignore dates * position loader icon fixed - fixes #1330 * permission problem when creating a new project - fixes #1340 * remove dev dependencies webserver and thanks bundle * stop information leak (begin and end date) in duration mode - fixes #1307 * unify timesheet edit dialog for user and admins * fix security issue, own rates exposed to unauthorized users in multi-update dialog
This commit is contained in:
@@ -22,6 +22,7 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
|
||||
use Symfony\Component\Validator\Test\ConstraintViolationAssertion;
|
||||
|
||||
/**
|
||||
* @covers \App\Validator\Constraints\TimesheetValidator
|
||||
@@ -199,4 +200,68 @@ class TimesheetValidatorTest extends ConstraintValidatorTestCase
|
||||
->setCode(TimesheetConstraint::DISABLED_CUSTOMER_ERROR)
|
||||
->assertRaised();
|
||||
}
|
||||
|
||||
public function getProjectStartEndTestData()
|
||||
{
|
||||
yield [new \DateTime(), new \DateTime(), [
|
||||
['begin', TimesheetConstraint::PROJECT_NOT_STARTED, 'The project has not started at that time.'],
|
||||
['end', TimesheetConstraint::PROJECT_NOT_STARTED, 'The project has not started at that time.'],
|
||||
]];
|
||||
|
||||
yield [new \DateTime('-9 hour'), new \DateTime('-2 hour'), [
|
||||
['begin', TimesheetConstraint::PROJECT_NOT_STARTED, 'The project has not started at that time.'],
|
||||
['end', TimesheetConstraint::PROJECT_ALREADY_ENDED, 'The project is finished at that time.'],
|
||||
]];
|
||||
|
||||
yield [new \DateTime('-19 hour'), new \DateTime('-12 hour'), [
|
||||
['begin', TimesheetConstraint::PROJECT_ALREADY_ENDED, 'The project is finished at that time.'],
|
||||
['end', TimesheetConstraint::PROJECT_ALREADY_ENDED, 'The project is finished at that time.'],
|
||||
]];
|
||||
|
||||
yield [new \DateTime('-19 hour'), new \DateTime('-2 hour'), [
|
||||
['end', TimesheetConstraint::PROJECT_ALREADY_ENDED, 'The project is finished at that time.'],
|
||||
]];
|
||||
|
||||
yield [new \DateTime('-9 hour'), new \DateTime(), [
|
||||
['begin', TimesheetConstraint::PROJECT_NOT_STARTED, 'The project has not started at that time.'],
|
||||
]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getProjectStartEndTestData
|
||||
*/
|
||||
public function testEndBeforeWithProjectStartAndEnd(\DateTime $start, \DateTime $end, array $violations)
|
||||
{
|
||||
$timesheet = new Timesheet();
|
||||
$timesheet->setBegin(new \DateTime('-10 hour'));
|
||||
$timesheet->setEnd(new \DateTime('-1 hour'));
|
||||
|
||||
$customer = new Customer();
|
||||
$project = new Project();
|
||||
$project->setStart($start);
|
||||
$project->setEnd($end);
|
||||
$project->setCustomer($customer);
|
||||
|
||||
$timesheet->setProject($project);
|
||||
$timesheet->setActivity(new Activity());
|
||||
|
||||
$this->validator->validate($timesheet, new TimesheetConstraint(['message' => 'myMessage']));
|
||||
|
||||
/** @var ConstraintViolationAssertion $assertion */
|
||||
$assertion = null;
|
||||
foreach ($violations as $violation) {
|
||||
if (null === $assertion) {
|
||||
$assertion = $this->buildViolation($violation[2])
|
||||
->atPath('property.path.' . $violation[0])
|
||||
->setCode($violation[1])
|
||||
;
|
||||
} else {
|
||||
$assertion = $assertion->buildNextViolation($violation[2])
|
||||
->atPath('property.path.' . $violation[0])
|
||||
->setCode($violation[1])
|
||||
;
|
||||
}
|
||||
}
|
||||
$assertion->assertRaised();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user