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

Command icon 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:

Comments

Sam152 created an issue. See original summary.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

joshmiller’s picture

Issue summary: View changes
benjifisher’s picture

I 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?

benjifisher’s picture

Issue tags: +Nashville2018, +Novice
runeasgar’s picture

I 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.

runeasgar’s picture

Alas, I fall victim to the ambiguity @benjifisher noted. I'm unable to discern whether we intend to change ConstraintsTest or TypedConfigTest. Moving on!

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

AJV009 made their first commit to this issue’s fork.

ajv009’s picture

Assigned: Unassigned » ajv009

Would 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?

benjifisher’s picture

@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 ClassName and ClassNameTest convention very discoverable."

#10 quotes that line, then adds a patch with

+/**
+ * Tests the machine name constraint.
+ *
+ * @see \Drupal\Core\Validation\Plugin\Validation\Constraint\MachineNameConstraint
+ * @see \Drupal\Core\Validation\Plugin\Validation\Constraint\MachineNameConstraintValidator
+ *
+ * @group Validation
+ */
+class MachineNameConstraintTest extends KernelTestBase {

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 at MachineNameConstraint, you can search for the test class.

Looking at the two classes core/tests/Drupal/KernelTests/Core/Validation/ConstraintsTest.php and core/tests/Drupal/KernelTests/Config/TypedConfigTest.php, it seems that the first one is testing UuidConstraint. I think that means the title of this issue is correct and the reference to TypedConfigTest is a mistake.

Checking the Git history, I see that both UuidConstraint and ConstraintsTest were 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:

Tests various low level constrains provided by core.

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.

benjifisher’s picture

... 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?

If 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.

ajv009’s picture

Am just a Novice hunting for novice issues to understand Drupal and its architecture!

The issue summary still needs an update: as I asked in #4, why are we doing this?

Looking at the two classes core/tests/Drupal/KernelTests/Core/Validation/ConstraintsTest.php and core/tests/Drupal/KernelTests/Config/TypedConfigTest.php, it seems that the first one is testing UuidConstraint. I think that means the title of this issue is correct and the reference to TypedConfigTest is a mistake.

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!

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Assigned: ajv009 » Unassigned
Issue summary: View changes
Issue tags: -Needs issue summary update

I 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.

yujiman85’s picture

Assigned: Unassigned » yujiman85

Assigned to myself to take a look and make the required changes.

yujiman85’s picture

Assigned: yujiman85 » Unassigned
Status: Active » Needs review

Needs a review.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Believe rename and description is correct.

Nice work!

  • longwave committed 70202c66 on 10.3.x
    Issue #2923168 by AJV009, Yujiman85, benjifisher, runeasgar: Rename...

  • longwave committed 39c6aa5c on 10.4.x
    Issue #2923168 by AJV009, Yujiman85, benjifisher, runeasgar: Rename...

  • longwave committed 1372de8d on 11.0.x
    Issue #2923168 by AJV009, Yujiman85, benjifisher, runeasgar: Rename...

  • longwave committed ee585649 on 11.x
    Issue #2923168 by AJV009, Yujiman85, benjifisher, runeasgar: Rename...
longwave’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Backported 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

znerol’s picture