stable

Clone or download

Read-only

Refactoring: configure ArtifactLink validation with context

Part of story #16125 [release management] create a new Aggregator Release No functional change expected. This refactoring has two goals: 1. Break artifact link validation out of the FormElement_Field inheritance. This allows us to NOT have to modify every field in Tuleap because we are changing a method signature like validate(). This is partially successful here: ArtifactLinkValidator is called directly by the general "FieldsValidator". We must still call $field->validateFieldWithPermissionsAndRequiredStatus() to check basic things like permissions and "required". 2. Configure artifact link validation with an object. The object allows us to change the validation (disable some checks) based on the kind of action we are doing. In the next patch, it will let us allow the creation of an artifact link that is usually not editable. Hence the names "SystemAction" where the systemis allowed to create those links, but for "ManualAction" it is not allowed. Change-Id: I2bd1c19eaf92b2479985a217e7b8960890f762a7

Modified Files

Name
M plugins/multi_project_backlog/include/Aggregator/Milestone/Mirroring/MirrorMilestonesCreator.php +4 −1 Go to diff View file
M plugins/multi_project_backlog/include/multi_project_backlogPlugin.php +14 −5 Go to diff View file
M plugins/multi_project_backlog/tests/unit/Aggregator/Milestone/Mirroring/MirrorMilestonesCreatorTest.php +3 −2 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Changeset/FieldsValidator.class.php +51 −6 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Changeset/InitialChanagesetFieldsValidator.class.php +1 −1 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Changeset/InitialChangesetCreatorBase.class.php +13 −8 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Changeset/NewChangesetCreatorBase.class.php +7 −1 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Changeset/NewChangesetFieldsValidator.class.php +4 −2 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/Changeset/Validation/ChangesetValidationContext.php +33 −0 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/Changeset/Validation/ChangesetWithFieldsValidationContext.php +46 −0 Go to diff View file
A plugins/tracker/include/Tracker/Artifact/Changeset/Validation/NullChangesetValidationContext.php +38 −0 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Tracker_Artifact.class.php +22 −2 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Tracker_ArtifactCreator.class.php +39 −12 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/Tracker_ArtifactFactory.class.php +53 −24 Go to diff View file
M plugins/tracker/include/Tracker/Artifact/XMLImportBuilder.class.php +16 −6 Go to diff View file
M plugins/tracker/include/Tracker/FormElement/ArtifactLinkValidator.php +19 −7 Go to diff View file
A plugins/tracker/include/Tracker/FormElement/Field/ArtifactLink/Validation/ArtifactLinkValidationContext.php +31 −0 Go to diff View file
A plugins/tracker/include/Tracker/FormElement/Field/ArtifactLink/Validation/ManualActionContext.php +34 −0 Go to diff View file
A plugins/tracker/include/Tracker/FormElement/Field/ArtifactLink/Validation/SystemActionContext.php +34 −0 Go to diff View file
M plugins/tracker/include/Tracker/FormElement/Tracker_FormElement_Field_ArtifactLink.class.php +12 −18 Go to diff View file
M plugins/tracker/include/Tracker/Migration/MigrationManager.php +12 −3 Go to diff View file
M plugins/tracker/include/Tracker/Tracker.class.php +35 −8 Go to diff View file
M plugins/tracker/tests/unit/Artifact/Changeset/Tracker_Artifact_Changeset_InitialChangesetCreatorTest.php +101 −15 Go to diff View file
M plugins/tracker/tests/unit/Artifact/Changeset/Tracker_Artifact_Changeset_InitialChangesetFieldsValidatorTest.php +115 −14 Go to diff View file
M plugins/tracker/tests/unit/Artifact/Changeset/Tracker_Artifact_Changeset_NewChangesetFieldsValidatorTest.php +76 −8 Go to diff View file
A plugins/tracker/tests/unit/Artifact/Changeset/Validation/NullChangesetValidationContextTest.php +33 −0 Go to diff View file
M plugins/tracker/tests/unit/Tracker/Artifact/Tracker_ArtifactCreatorTest.php +36 −29 Go to diff View file
M plugins/tracker/tests/unit/Tracker/FormElement/ArtifactLinkValidatorTest.php +173 −40 Go to diff View file