Problem/Motivation
The test \Drupal\KernelTests\Core\Validation\ConstraintsTest does not have a meaningful name because it does not state what constraint is being validated.
Proposed resolution
Rename \Drupal\KernelTests\Core\Validation\ConstraintsTest to \Drupal\KernelTests\Core\Validation\UuidValidatorTest
Remaining tasks
Create an MR
Review
Commit
User interface changes
None
API changes
None
Data model changes
None
Original report by [username]
Follow up to #2920678: Add config validation for the allowed characters of machine names
Issue fork drupal-2923168
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 2923168-rename-constraintstest-to
changes, plain diff MR !9214
Comments
Comment #3
joshmillerComment #4
benjifisherI rewrote the issue summary, using the standard template. I added the "Needs issue summary update" tag because we need to explain why we are doing this. Please fill out the first two sections of the template. This will make it easier for reviewers.
The comments on #2920678: Add config validation for the allowed characters of machine names say "We should convert TypedConfigTest into UuidValidatorTest" before this issue was created. Which class do we want to rename?
Comment #5
benjifisherComment #6
runeasgar commentedI am at the DrupalCon Nashville 2018 mentored sprint. I'm going to try to make a patch for this.. but in all likelihood I will fail miserably :) so please don't take this as a sign that you shouldn't work on the issue if you want to.
Comment #7
runeasgar commentedAlas, I fall victim to the ambiguity @benjifisher noted. I'm unable to discern whether we intend to change ConstraintsTest or TypedConfigTest. Moving on!
Comment #14
ajv009 commentedWould love to have more clarity on this issue, I did go through the whole thread and the reference here - https://www.drupal.org/project/drupal/issues/2920678#comment-12339226
Did check the code, so I guess 'ConstraintsTest' has to be changed to 'UuidValidatorTest', But then I also feel with name some code and path may also have to change, right?
Comment #15
benjifisher@AJV009:
The issue summary still needs an update: as I asked in #4, why are we doing this?
Review some of the comment from #2920678: Add config validation for the allowed characters of machine names:
#8: "I always find the
ClassNameandClassNameTestconvention very discoverable."#10 quotes that line, then adds a patch with
This test class is following the pattern discussed in the comments. If you are looking at the test class, you can tell that it tests
MachineNameConstraint, and if you are looking atMachineNameConstraint, you can search for the test class.Looking at the two classes
core/tests/Drupal/KernelTests/Core/Validation/ConstraintsTest.phpandcore/tests/Drupal/KernelTests/Config/TypedConfigTest.php, it seems that the first one is testingUuidConstraint. I think that means the title of this issue is correct and the reference toTypedConfigTestis a mistake.Checking the Git history, I see that both
UuidConstraintandConstraintsTestwere added in #2870878: Add config validation for UUIDs. You should read the comments on that issue and compare to the comment in the current code:Maybe the original intention was to have tests for several classes in that one test class. Since then, either no one got around to it or we decided to have separate test classes.
Comment #16
benjifisherIf I understand your question correctly, then yes: if we change the name of the class, then we also have to rename the file to match. The namespace and the directory have to match, too: if we leave both of them the same, that is fine.
You should also update the doc block I quoted near the end of #15. Use the earlier code snippet as a model.
Comment #17
ajv009 commentedAm just a Novice hunting for novice issues to understand Drupal and its architecture!
IDK, But yeah that's close to what I understood by going through that thread!
You right the issue summary needs to be updated first before making any patches with the suggestions and thread discussions, I'll do it!
Comment #23
quietone commentedI read the other issue and looked at the files. The file \Drupal\KernelTests\Core\Validation\ConstraintsTest is the file that is testing UUID, so the title here is correct.
This is suitable for a novice, leaving the tag.
Comment #24
yujiman85 commentedAssigned to myself to take a look and make the required changes.
Comment #26
yujiman85 commentedNeeds a review.
Comment #27
smustgrave commentedBelieve rename and description is correct.
Nice work!
Comment #33
longwaveBackported down to 10.3.x as a test-only fix.
Committed and pushed ee58564958 to 11.x and 1372de8d7e to 11.0.x and 39c6aa5c56 to 10.4.x and 70202c66bc to 10.3.x. Thanks!
Comment #35
znerol commentedFollow-up: #3523649: Extract testUriHost from UuidValidatorTest into its own class.