stable

Clone or download

Read-only

Have a dedicated object to represent an incomplete program

Part of story #21793 configure Program Management No functional change expected: - Non project administrator users cannot access Program Management admin - Access to Program Management admin is denied for projects that are Teams Notes to reviewers: Using dedicated objects is preferable to primitive types (see Primitive obsession smell [0]) as we can enforce some verifications when building the object. Here, we enforce verifying that a potential program being configured (a ProgramInConfigurationIdentifier) cannot be a Team and the current user must be administrator of it. Using an int, we cannot enforce this verification everytime. With a dedicated object, the only way to get this object is to do the verification, so we can be sure it is done. VerifyProjectPermission interface may seem useless: we can just call a method on PFUser. But this method is badly designed: it creates a new DAO (without injection) and accesses the database, so using it forces us to use mocks of PFUser. Using an interface lets us have mock-free tests and isolates the database access from the domain. It is better from an hexagonal architecture point of view. There is some duplication in the code with ProgramForManagement for example; it should be dealt with in future commits. [0] http://www.jamesshore.com/v2/blog/2005/primitiveobsession Change-Id: Ifb1519f00de30b5094314de6f56b804880afc7d0

Modified Files

Name
A plugins/program_management/include/Adapter/Workspace/ProjectPermissionVerifier.php +33 −0 Go to diff View file
M plugins/program_management/include/DisplayAdminProgramManagementController.php +23 −17 Go to diff View file
A plugins/program_management/include/Domain/Program/Admin/ProgramCannotBeATeamException.php +47 −0 Go to diff View file
A plugins/program_management/include/Domain/Program/Admin/ProgramInConfigurationIdentifier.php +65 −0 Go to diff View file
M plugins/program_management/include/Domain/Program/Backlog/ProgramIncrement/Team/TeamProjectsCollection.php +15 −6 Go to diff View file
M plugins/program_management/include/Domain/Program/ProgramIdentifier.php +3 −0 Go to diff View file
A plugins/program_management/include/Domain/Workspace/VerifyProjectPermission.php +28 −0 Go to diff View file
M plugins/program_management/include/program_managementPlugin.php +6 −3 Go to diff View file
M plugins/program_management/site-content/fr_FR/LC_MESSAGES/tuleap-program_management.po +8 −1 Go to diff View file
A plugins/program_management/tests/unit/Adapter/Workspace/ProjectPermissionVerifierTest.php +41 −0 Go to diff View file
M plugins/program_management/tests/unit/DisplayAdminProgramManagementControllerTest.php +27 −34 Go to diff View file
A plugins/program_management/tests/unit/Domain/Program/Admin/ProgramInConfigurationIdentifierTest.php +84 −0 Go to diff View file
M plugins/program_management/tests/unit/Domain/Program/Backlog/ProgramIncrement/Team/TeamProjectsCollectionTest.php +43 −15 Go to diff View file
A plugins/program_management/tests/unit/Stub/VerifyProjectPermissionStub.php +50 −0 Go to diff View file